Well, I just started my C# programming class at CC, and it's my first time learning a programming language (It's an intro class, but I skipped the recommended class to fit my schedule.) Is there anything difficult or anything important I should know about this language? I know about the other C languages, but, nothing about C#
The only thing I'll say about C# is that it's hard to learn that first, and then move on to something else. Mainly because you get so spoiled with .NET.
C# is a great language. It's part of the .NET framework, which will come to know very well. .NET provides you with tons of class libraries to quickly create powerful applications.
I reccomend bookmarking the MSDN library, which documents all of these class libraries and is pretty easy to search around (get the client-side version if you can, I think it costs money but it's way faster).
*edit* I don't know about hard to learn. I think that the .NET framework and application structure is actually the hard part to learn (or get used to, I should say). C# has a very clean and logical syntax as opposed to VB.NET.
Well, I just started my C# programming class at CC, and it's my first time learning a programming language (It's an intro class, but I skipped the recommended class to fit my schedule.) Is there anything difficult or anything important I should know about this language? I know about the other C languages, but, nothing about C#
This advice won't make much sense to you until you've had a few classes, but remember that it's always better to return than to mutate. The more variables your class has, the worse it's designed.
What this means is, do not write code like this:
class MyClass
{
int first, second, result;
void multiply ()
{
result = first * second;
}
void print2By2 () // Example
{
first = 2;
second = 2;
multiply ();
Console.WriteLine (result);
}
}
Instead, write it like this:
class MyClass
{
int multiply (int first, int second)
{
return first * second;
}
void print2By2 () // Example
{
int result = multiply (2, 2);
Console.WriteLine (result);
}
}
If you're familiar with c/c++, then c# should be an absolute breeze.
Honestly, the closest analog to c# is java. I have taken code from java and made only minor syntax changes and had it execute perfectly (which is also a tribute to good design).
I can't really give you any tips on learning it other than take your time and just dig in. Like any other language, start with small problems and work your way up - don't rush into building a complicated app. There's a reason why all books start with hello world
If you're not a novice to programming, and looking for some design tips, I'd definitely encourage you to look at a lot of the java packages that have been ported. I'm not a java snob (rarely use it), but all of the best libraries I use are ports. Let's face it, they've had time to mature. Examples: Spring.Net, NHibernate for the web arena.
Well, I just started my C# programming class at CC, and it's my first time learning a programming language (It's an intro class, but I skipped the recommended class to fit my schedule.) Is there anything difficult or anything important I should know about this language? I know about the other C languages, but, nothing about C#
class MyClass
{
void multiply (int first, int second)
{
return first * second;
}
void print2By2 () // Example
{
int result = multiply (2, 2);
Console.WriteLine (result);
}
}
You could also make multiply a variable itself and make the code even shorter:
int multiply(int first, int second)
{
return first * second;
}
void main()
{
Console.WriteLine(multiply(2, 2));
}
This way you don't have to declare the variable and set the value to the result of the function.
The function itself returns the variable and you can pass it off into whatever you need to use the result in.
multiply() is now data typed and can be called anywhere you would insert an integer.
Soviet, are you using C# for windows application development, or web application development?
Jasconius on
0
Options
Zxerolfor the smaller pieces, my shovel wouldn't doso i took off my boot and used my shoeRegistered Userregular
edited August 2007
C# as a language isn't anything particularly new or mindblowing. It's great and elegant, sure. But the goodies are exposed in the the .NET libraries. It was almost trivially easy for me to write a tool to synchronize my domain's Active Directory user list with an external database in C#. With Windows Forms, I don't want to look at MFC or the Windows API and message pumps ever again. It's wonderful stuff.
Posts
Thanks for letting me know I made a good choice
I reccomend bookmarking the MSDN library, which documents all of these class libraries and is pretty easy to search around (get the client-side version if you can, I think it costs money but it's way faster).
*edit* I don't know about hard to learn. I think that the .NET framework and application structure is actually the hard part to learn (or get used to, I should say). C# has a very clean and logical syntax as opposed to VB.NET.
This advice won't make much sense to you until you've had a few classes, but remember that it's always better to return than to mutate. The more variables your class has, the worse it's designed.
What this means is, do not write code like this:
Instead, write it like this:
This is true.
Not quite so true.
Honestly, the closest analog to c# is java. I have taken code from java and made only minor syntax changes and had it execute perfectly (which is also a tribute to good design).
I can't really give you any tips on learning it other than take your time and just dig in. Like any other language, start with small problems and work your way up - don't rush into building a complicated app. There's a reason why all books start with hello world
If you're not a novice to programming, and looking for some design tips, I'd definitely encourage you to look at a lot of the java packages that have been ported. I'm not a java snob (rarely use it), but all of the best libraries I use are ports. Let's face it, they've had time to mature. Examples: Spring.Net, NHibernate for the web arena.
You could also make multiply a variable itself and make the code even shorter:
This way you don't have to declare the variable and set the value to the result of the function.
The function itself returns the variable and you can pass it off into whatever you need to use the result in.
multiply() is now data typed and can be called anywhere you would insert an integer.
Soviet, are you using C# for windows application development, or web application development?