Re: what static fuction mean in c#

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Guido Stercken-Sorrenti [MVP VC++]" <mspbn@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23je1Z2X0FHA.2880@xxxxxxxxxxxxxxxxxxxxxxx
>> when i was usong c++ idont have to put static before tha function that i want
>> to acces but in c# i have to but it .
>
> Well, in both languages you have to declare a member function as static if you want to call that
> function without an instance of the class - it's the same in both languages. In C++, like in C#,
> you need an instance to call a nonstatic member function. I don't see why you think this would be
> different?
>

The difference is that in C++ you can declare functions outside of any class. (like in C)
In C# all functions/methods must be part of a Class.
If you don't declare the method as static it means that it is associated with a particular OBJECT.
If you do declare the method as static it means that it is associated with the CLASS.

Bill


.



Relevant Pages

  • Re: New to class why am I having sooo much trouble accessing privates
    ... > declare the function in public as ... void test::FormatARAYMember function of class test. ... house is a dead thing. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: creating thread in C++
    ... and you can't declare static member this way. ... OS/2 for instance uses a different calling convention for class members which cannot be changed. ... The work around is to use a friend instead of a static class member function. ... But I am unsure if a static function declaration within an extern "C" block is guaranteed. ...
    (comp.programming.threads)
  • Re: Object Initialization in C++
    ... > In this case I want to call the Description Member Function depending ... Declare Description to be a virtual function in Vehicle. ...
    (comp.lang.cpp)
  • Re: Problem with __cdecl
    ... > If i declare the function as ... you can't pass a member function where a non-member ... these callback mechanisms often provide a means to pass "user ... but the first "void*" parameter may be ...
    (comp.lang.cpp)
  • Re: what static fuction mean in c#
    ... in both languages you have to declare a member function as static if ... same in both languages. ... nonstatic member function. ...
    (microsoft.public.dotnet.languages.csharp)