about classes in C#
Hi all,
I am a beginner to C# programming. Just wanted to know, how to identify and add specific header files, for using some methods in any built-in classes in console application. for eg. what header file has to be included to perform udp socket connection in the project.
Raaj KumarPosted Mar 8, 2010, 1:53 AM
In Visual Studio there is a window called Object Explorer. Using this you can easily identify the namespace of a method. For opening ObjectExplorer goto View-->Object Explorer or press Ctrl+W,J. In Search TextBox type your classname or method or property and it will show the namespace, class name and you can browse the entire assembly.
Regards,
raaj
Raaj KumarPosted Mar 9, 2010, 12:24 AM
As I mentioned earlier you can see the list of methods and properties using this Object Browser. If you need more help you can make use of MSDN site where an example is provided along with the member methods and variables.
Regards,
raaj
Soumya BPosted Mar 8, 2010, 11:43 PM
Sam HobbsPosted Mar 8, 2010, 2:01 AM
I assume you are experienced with C++. C# and .Net work differently, obviously. For C#, you need to have references and usings. The "using" statements go at the top, like #include, but the using statement in C# just specifies default namespaces, as in "using namespace std" in C++. In the Solution Explorer, look at the References node; you need to add references there. So for UDP, look at the documentation of the UdpClient Class. At the top of the documentation it says:
Namespace:
Assembly: System (in System.dll)
So you need to add a reference to System.Net.Sockets and have "using System;" at the top of the program. That does not sound correect to me; I think it would be "using System.Net.Sockets;", but the documentation is probably correct.