Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Static Class
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
01028423
Message ID:
01028722
Vues:
19
Ok, I understand that. But if the methods both exists on the class,
and only non-static are available on instances, I should still be
able to then access the non-static.


>Kevin,
>
>I think you're talking about why you can't access both methods in the intellisense for the instantiated version of the class? If I'm wrong ignore all that follows :)
>
>Static methods apply to all instances of a class, so if you have 10 instances they are not using a method on the object, they are using a method on the class. This is why you cannot see the static methods in the intellisense for an instance of the class, but you can when you reference the class directly.
>
>This has been done on purpose, so it is absolutely clear when you are using a member of a specific instance or of a class as a whole. What you are seeing is two different aspects of the class.
>
>
>>I'm just starting out with C#.Net so I have no idea
>>why I would need to do this.
>
>>But in the example below, there are 2 methods in
>>the class. I don't full understand why you cannot
>>access both static and non static methods.
>
>>Kevin,
>>
>>Can you give us an example of why you'd need to do this? Then maybe we can come up with an easy solution.
>>
>>~~Bonnie
>>
>>
>>>You misunderstood my question.
>>>
>>>Intellisense doesn show both methods at once. So how
>>>do you call both if you need to?
>>>
>>>
>>>
>>>
>>>>>
>
>>>>>Class1 oTest = new Class1();
>>>>>oTest.Method1(); // Method1 is not static
>>>>>
>>>>>Test1.Class1.Method2(); // Method2 is static
>>>>>
>
>
>>>>>
>>>>>What if I had to call both Method1 and Method2?
>>>>
>>>>I don't think that would be a problem. But I'm not sure what the advantage would be of designing a class that works like you describe.
>>>>
>>>>Malcolm
>
>Everything makes sense in someone's mind
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform