Click here to Skip to main content
15,890,897 members
Home / Discussions / C#
   

C#

 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
Mark Salsbery16-May-09 9:20
Mark Salsbery16-May-09 9:20 
AnswerRe: C++ virtual destructor in C#? Why not? Pin
Guffa16-May-09 16:46
Guffa16-May-09 16:46 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
devvvy16-May-09 17:04
devvvy16-May-09 17:04 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
Guffa22-May-09 13:27
Guffa22-May-09 13:27 
QuestionUse methods from another form Pin
michaelgr116-May-09 2:08
michaelgr116-May-09 2:08 
AnswerRe: Use methods from another form Pin
OriginalGriff16-May-09 2:39
mveOriginalGriff16-May-09 2:39 
AnswerRe: Use methods from another form Pin
michaelgr116-May-09 3:03
michaelgr116-May-09 3:03 
GeneralRe: Use methods from another form Pin
OriginalGriff16-May-09 3:53
mveOriginalGriff16-May-09 3:53 
Oh Boy!

This is a bit fundamental, so I'll try to explain, but it is probably better explained in any of the many books on C# out there.

You can use a static method at any time: String.Format(...) is a static method. You give it as a command:
string s = String.Format("The result is {0}", 6 * 9);

and it evaluates to a string "The result is 54".

You use a non-static method when you want it work on an object: an instance of the class.
class Example
   {
   public string data;
   public int CountChars()
      {
      return data.Length;
      }
   }

...

   Example ex = new Example();
   ex.data = "ABCDEFGHIJKLM";
   int i = ex.CountChars();

...

ex is an instance of the Example class, so you can call CountChars on ex, and it will work on the data that is relevant to ex only. If you declare another variable ex2, then ex.CountChars() and ex2.CountChars() will return different values, depending on what data you have fed them.

Static methods can only access static data (and other static methods). In the Example class, you cannot define a static method that can access the "data" string, because it is non-static.

Does that make sense?

No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.

This message is made of fully recyclable Zeros and Ones

AnswerRe: Use methods from another form Pin
Manas Bhardwaj16-May-09 6:20
professionalManas Bhardwaj16-May-09 6:20 
GeneralRe: Use methods from another form Pin
michaelgr116-May-09 6:33
michaelgr116-May-09 6:33 
GeneralRe: Use methods from another form Pin
Dave Kreskowiak16-May-09 17:24
mveDave Kreskowiak16-May-09 17:24 
QuestionDataGridView CellPainting Performance Issue Pin
John Jak16-May-09 2:08
John Jak16-May-09 2:08 
QuestionOCR using Abby Finereader in C# Pin
makimca16-May-09 1:33
makimca16-May-09 1:33 
AnswerRe: OCR using Abby Finereader in C# Pin
incaunu16-Jul-09 3:20
incaunu16-Jul-09 3:20 
AnswerRe: OCR using Abby Finereader in C# Pin
shparmar17-Nov-10 23:03
shparmar17-Nov-10 23:03 
Questiongraph Pin
shanmugam_1316-May-09 0:45
shanmugam_1316-May-09 0:45 
AnswerRe: graph Pin
Rajesh R Subramanian16-May-09 1:16
professionalRajesh R Subramanian16-May-09 1:16 
GeneralRe: graph Pin
Manas Bhardwaj16-May-09 6:23
professionalManas Bhardwaj16-May-09 6:23 
GeneralRe: graph Pin
Rajesh R Subramanian16-May-09 19:11
professionalRajesh R Subramanian16-May-09 19:11 
Questionwho do i add atext to textbox in section1 in crystalreport Pin
Member 439903616-May-09 0:30
Member 439903616-May-09 0:30 
QuestionTwo C#.Net questions Pin
Roland Szigeti16-May-09 0:21
Roland Szigeti16-May-09 0:21 
AnswerRe: Two C#.Net questions Pin
PIEBALDconsult16-May-09 3:26
mvePIEBALDconsult16-May-09 3:26 
GeneralRe: Two C#.Net questions Pin
Roland Szigeti16-May-09 3:56
Roland Szigeti16-May-09 3:56 
GeneralRe: Two C#.Net questions Pin
PIEBALDconsult16-May-09 7:35
mvePIEBALDconsult16-May-09 7:35 
GeneralRe: Two C#.Net questions Pin
Roland Szigeti16-May-09 8:14
Roland Szigeti16-May-09 8:14 

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.