using System;
namespace LearnCS
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i <= 500; i = i + 10) {
Console.WriteLine(i);
}
}
}
}
using System;
namespace LearnCS
{
class Program
{
static void Main(string[] args)
{
int lang = 500;
switch (lang) {
case 1:
Console.WriteLine("Perl");
break;
case 2:
Console.WriteLine("Python");
break;
case 3:
Console.WriteLine("C++");
break;
case 4:
Console.WriteLine("PHP");
break;
case 5:
Console.WriteLine("Java");
break;
default:
Console.WriteLine("Unknown");
break;
}
}
}
}
using System;
namespace LearnCS
{
class Program
{
static void Main(string[] args)
{
if (25 > 50) {
Console.WriteLine("25 is G reater than 50");
}
if (25 < 50) {
Console.WriteLine("25 is Smaller than 50");
}
if (25 == 25)
{
Console.WriteLine("Numbers are Equal");
}
}
}
}
using System;
namespace LearnCS
{
class Program
{
static void Main(string[] args)
{
if (100 > 50) {
Console.WriteLine("100 is Greater than 50");
}
if (25 < 50) {
Console.WriteLine("25 is Smaller than 50");
}
if (50 == 50) {
Console.WriteLine("Number are Equal");
}
}
}
}
using System;
namespace LearnCS
{
class Program
{
static void Main(string[] args)
{
int x = 50;
int y = 50;
if (x > y)
{
Console.WriteLine(x + " is Greater than " + y);
}
else if (x < y)
{
Console.WriteLine(x + " is Smaller than " + y);
}
else {
Console.WriteLine("Numbers are Equal");
}
}
}
}
using System;
namespace LearnCS
{
class Program
{
static void Main(string[] args)
{
string someString = "Of all things i've lost i miss my mind the most";
Console.WriteLine("Length: " + someString.Length);
Console.WriteLine("To Upper: " + someString.ToUpper());
Console.WriteLine("To Lower: " + someString.ToLower());
string oneMore = " Hack The Planet";
string result = string.Concat(someString, oneMore);
Console.WriteLine(result);
string interpolation = $"First One: {someString} and Second One: {oneMore}";
Console.WriteLine(interpolation);
Console.WriteLine(someString[0]);
Console.WriteLine(someString[1]);
Console.WriteLine(someString[2]);
Console.WriteLine(someString[3]);
Console.WriteLine(someString[4]);
Console.WriteLine(someString.IndexOf("t"));
Console.ReadLine();
}
}
}
C# (pronounced "C sharp") is a modern, multi-paradigm programming language developed by Microsoft in the early 2000s.
It is designed to be simple, safe, and efficient, and is widely used for developing a variety of applications on the .NET framework, including Windows desktop applications, web applications, mobile apps, games, and more.
The .NET Framework is a software framework developed by Microsoft that provides a platform for building, deploying, and running applications. It includes a large library of pre-built code and tools that developers can use to create a wide range of applications.
using System;
namespace LearnCS
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Some String");
}
}
}
Quick explanation, for now:
This C# code defines a class called Program inside a namespace called LearnCS. The Main method is the entry point of the program, which is executed when the program starts.
Inside the Main method, a message "Some String" is printed to the console using the Console.WriteLine method.
In order to use the Console class, the System namespace is being imported using the using keyword at the beginning of the file.