Click here to Skip to main content
15,888,802 members
Home / Discussions / C#
   

C#

 
GeneralRe: Few question about static class c# Pin
Tridip Bhattacharjee25-Mar-13 8:46
professionalTridip Bhattacharjee25-Mar-13 8:46 
GeneralRe: Few question about static class c# Pin
Marco Bertschi25-Mar-13 9:35
protectorMarco Bertschi25-Mar-13 9:35 
GeneralRe: Few question about static class c# Pin
Tridip Bhattacharjee25-Mar-13 9:53
professionalTridip Bhattacharjee25-Mar-13 9:53 
GeneralRe: Few question about static class c# Pin
Marco Bertschi25-Mar-13 10:16
protectorMarco Bertschi25-Mar-13 10:16 
GeneralRe: Few question about static class c# Pin
Tridip Bhattacharjee25-Mar-13 21:31
professionalTridip Bhattacharjee25-Mar-13 21:31 
GeneralRe: Few question about static class c# Pin
Marco Bertschi25-Mar-13 22:20
protectorMarco Bertschi25-Mar-13 22:20 
AnswerRe: Few question about static class c# Pin
DaveyM6925-Mar-13 9:45
professionalDaveyM6925-Mar-13 9:45 
AnswerRe: Few question about static class c# Pin
V.25-Mar-13 23:04
professionalV.25-Mar-13 23:04 
A normal class is instantiated to an object and you can create many objects with that class. (thus you can see a class as a template for creating objects, each with its own properties)

A static class on the other hand cannot create objects at all. it can hold an algorithm (functions/methods) or some data, but it doesn't belong to anything.

C#
//Suppose a Class car with properties color and speed and methods accelerate and turn.
// you can do this:
Car red_car = new Car();
Car blue_car = new Car();
red_car.Speed = 100;
red_car.Color = Red;
blue_car.Speed = 65;
blue_car.Color = Blue;

// Now you have 2 instances of the class Car.  blue_car and red_car, each with its own properties.
// next lets execute an algorithm
red_car.Accelerate(-25);
blue_car.Accelerate(10);

//You'll notice that at this point:
//1) red_car and blue_car are different entities.
//2) I NEVER used the class Car as a reference to access properties or methods.


C#
//Suppose a static class MathConstants with properties Pi and e and a method CalculateCircleCircumfence.
// You can NOT do this:
//MathConstants mc = new MathConstants(); 

//You can do this:
double radius = 3.6;
double circumfence = MathConstants.CalculateCircleCircumfence(radius);
double americanpie = 3.141599999;
MathConstants.PI = americanpie;
//know our MathConstants.PI has changed for every usage from this point on.

//You'll notice that at this point:
//1) There are no different entities, because you cannot create them
//2) I ALWAYS used MathConstants to access properties and methods.


The real world is less black and white than this, but I hope it makes some issues clearer for you.

Questionhow memory is allocated for class, class data member and member function & interface and class instance ? Pin
Tridip Bhattacharjee25-Mar-13 4:59
professionalTridip Bhattacharjee25-Mar-13 4:59 
AnswerRe: how memory is allocated for class, class data member and member function & interface and class instance ? Pin
Paulo Zemek25-Mar-13 5:28
mvaPaulo Zemek25-Mar-13 5:28 
GeneralRe: how memory is allocated for class, class data member and member function & interface and class instance ? Pin
Tridip Bhattacharjee25-Mar-13 9:26
professionalTridip Bhattacharjee25-Mar-13 9:26 
GeneralRe: how memory is allocated for class, class data member and member function & interface and class instance ? Pin
Paulo Zemek25-Mar-13 9:46
mvaPaulo Zemek25-Mar-13 9:46 
QuestionAny C# library for Forward error correction. Pin
iamraghusunkara25-Mar-13 4:33
iamraghusunkara25-Mar-13 4:33 
AnswerRe: Any C# library for Forward error correction. Pin
Marco Bertschi25-Mar-13 6:17
protectorMarco Bertschi25-Mar-13 6:17 
AnswerRe: Any C# library for Forward error correction. Pin
unclepaul25-Mar-13 10:44
unclepaul25-Mar-13 10:44 
GeneralRe: Any C# library for Forward error correction. Pin
iamraghusunkara25-Mar-13 19:55
iamraghusunkara25-Mar-13 19:55 
QuestionRemote desktop using VNC Pin
superselector25-Mar-13 1:27
superselector25-Mar-13 1:27 
AnswerRe: Remote desktop using VNC Pin
Richard MacCutchan25-Mar-13 1:35
mveRichard MacCutchan25-Mar-13 1:35 
AnswerRe: Remote desktop using VNC Pin
Eddy Vluggen25-Mar-13 2:03
professionalEddy Vluggen25-Mar-13 2:03 
AnswerRe: Remote desktop using VNC Pin
Marco Bertschi25-Mar-13 6:22
protectorMarco Bertschi25-Mar-13 6:22 
Questiondelegate difficulty Pin
Member 993942324-Mar-13 21:45
Member 993942324-Mar-13 21:45 
AnswerRe: delegate difficulty Pin
Abhinav S24-Mar-13 22:29
Abhinav S24-Mar-13 22:29 
GeneralRe: delegate difficulty Pin
Member 993942325-Mar-13 3:42
Member 993942325-Mar-13 3:42 
GeneralRe: delegate difficulty Pin
PIEBALDconsult25-Mar-13 5:01
mvePIEBALDconsult25-Mar-13 5:01 
AnswerRe: delegate difficulty Pin
Paulo Zemek25-Mar-13 5:34
mvaPaulo Zemek25-Mar-13 5:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.