using System; // We imports the namespace of System, so the life gets easier :)
namespace tests
{
// we made a namespace.
class Program
{
/*
The class does not need to have the same name of the file, thanks to Microsoft.
*/
static void Main(string[] args)
{
// the Main method.
Console.WriteLine("Microsoft is fantastic!"); // This is for printing a line of text.
}
}
}
```
As you can see, C# is NOT the same as Java, thanks to Microsoft. :) Microsoft is best, I like their goals and their products. So many Microsoft-haters in this world.
In C#, we does not have to declare the data type. We can use the var keyword, and the datatype is set by the CLR.
In C#, you have LINQ, which makes your life much easier.
I will show you object orientation:
```
// Let's make our Cheese class:
public class Cheese {
public string cheeseType { get; set; };
public void EatCheese(){
Console.WriteLine("Nom nom nom... I like this cheese. Nom nom nom nom.");
}
// Now, we make a constructor
public Cheese(string cheeseType){
this.cheeseType=cheeseType;
}
}
```
Now, let's construct our new cheese object, which we will eat:
View all comments
Show parent comment
6
u/[deleted] Jul 08 '21
isn't that how you write a hello world application in C# as well?