General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 12th, 2002, 04:03 PM
ckchin ckchin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 52 ckchin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Article Wish List on Beginning C#

Hi,

I just started to learn the C#. I would like to have certain article talking about the basic things, like the ALL STRUCTURE of the C# functions and the basic use of them, etc.

For example:

static void Main() versus static void Main(string[] args)
static int Main () versus static int Main (string[] args)

static int functionname(int[] intArray)
the use of public and private

Since there is a static, do we have something called dynamic void()Main? Why we use static? Why we have "string[] args", etc.

If there is an tutorial or article talking about this on the Internet, could you please provide the url.
__________________
Regrads,

ckchin

Reply With Quote
  #2  
Old April 12th, 2002, 07:33 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 588 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
hi ckchin,
i can help you out with all of that...

first off:

the difference between static void Main() and static void Main(string[] args) is that the arguement to main can be used to pass in words from the command line, so if we create a C# console app called blah.exe and i called it like this:

blah.exe test1 test2 test3

then the args[] array in main would have three indexes which contained the string values "test1", "test2", and "test3". it's good for setting config options.

static int Main () versus static int Main (string[] args)
the int part is the return type of the function, so you'd have

int Blah()
{
return 0;
}

to return an integer, or

void Blah()
{

}

so you don't have to return anthing from the function.

in C#, all functions are encapsulated by a class. the static keyword means that you can call the function directly through the class and dont have to instantiate the class before hand, for example this would work:

class myClass
{
static void blah() {}

static void Main()
{
blah();
}
}

this code would also work:

class myClass
{
function Blah()
{

}
}

class appClass
{
static void Main()
{
myClass mc = new myClass();
myClass.Blah();
}
}

the following code wouldnt work however

class myClass
{
function Blah()
{

}
}

class appClass
{
static void Main()
{
myClass.Blah();
}
}

the code above doesnt work because the Blah() fnuction of myClass isn't static, meaning that its class must be instantiated (a new copy created) before it can be used...

there's no equivelant dynamic function, you simply don't include static at the front of the function name.

As for public, private, protected, abstract, etc they are access modifiers and you can use them to set the inheritance and access levels for functions. for example,

class myClass
{
private void Blah();
}

now if i derived a class from myClass, Blah() wouldn;t be accessible because it's private to the myClass function:

// This code wouldnt work
class myClass1 : myClass
{

}

myClass1 mc1 = new myClass1();
// Error here
mc1.Blah();

That's the general gist of things..syntax might be a bit out but you get the idea. here's some articles you might like to read:

http://www.softsteel.co.uk/tutorial...p/lesson11.html
http://www.pune-csharp.com/downloads/index.htm

Reply With Quote
  #3  
Old April 14th, 2002, 10:24 AM
James Yang James Yang is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Atlanta, Georgia
Posts: 284 James Yang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 45 sec
Reputation Power: 17
Send a message via ICQ to James Yang
Expanding on that,

when you define a method as static you are defining it as static cuz you know that there will only be one instance of that class thru out that application.

eg.
this class has 2 methods one is static and one is not

class A
{
static void staticMethod()
{}
void normalMethod()
{}
}

ok say you wanna use staticMethod. then you would do it like folowing

A.staticMethod();

if you wanna use nomalmethod then you would do it liek

A aInstance = new A();
aInstance.normalMethod();

This is really a feature of object oriented programming which isn't just about static and non static etc..

If you are willing to learn about this. There are books which just teaches you oop. eg this topic and more.including inhertence. Some of those books also have "WHEN" you can use these techniques and features which is most valuable if you are inexperienced programmer...

hope this helped
__________________
Regards,

James Yang
.NET Developer / Network Engineer
MCSE, MCDBA, MCSA, CCNA

http://www.yellowpin.com/
http://www.opentechsupport.com/

Reply With Quote
  #4  
Old April 14th, 2002, 02:46 PM
ckchin ckchin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 52 ckchin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Thanks. I would like to make sure the followings are correct.

1) none (no modifier) can be used to instantiated using ... new,
2) static is only class-based accessible
3) abstract cannot be instantiated using new, and must be overriden
4) extern ... what is this?
5) virtual ... On NO what is this again?
6) new ... another what is this, example?

I did read the C# beginning on the OOP chapter. This book only give example (very NOT clear examples) and did not listed down all the modifier and the use of them.

Actually I did have a list of questions, and would like to ask here. BUT, I will make sure I finished reading the tutorial from the http://www.pune-csharp.com/downloads/index.htm (It is a great tutorial, and Thanks to Mytch because you share this url to me), and make a clear view of OOP (at least the basic one in C#) before the list of question here.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Article Wish List on Beginning C#


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap