Re: what static fuction mean in c#



> 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?

--
Guido Stercken-Sorrenti
MVP - Visual Developer / Visual C++
"SemSem" <SemSem@xxxxxxxxxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:15C1C5E6-B944-493E-94C4-0AA9A18752B6@xxxxxxxxxxxxxxxx
> ihave a function called add(int x,int y)
> i have to put
> static int add(int x,int y) in prototype
> or i have this
> "an object refrence is required for the nonstatic field, methiod or
> property"
>
> i hope someone to tell me why as i think the idea of static in c# is not
> like in c++
> or tell me where to post this
>
> thanx at all
>
>
>


.



Relevant Pages

  • Re: Messages as first class objects
    ... This member function is a method. ... But how many languages allow you to take a ... In VisualWorks Smalltalk there are classes like ... > CompiledMethod and others that represent methods. ...
    (comp.object)
  • Re: what static fuction mean in c#
    ... >> to acces but in c# i have to but it. ... in both languages you have to declare a member function as static if you want to call that ... > you need an instance to call a nonstatic member function. ... The difference is that in C++ you can declare functions outside of any class. ...
    (microsoft.public.dotnet.languages.csharp)
  • 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)