CodeGurl Chronicles

CodeGurl Chronicles For those who are unemployed, looking for a job and want to progress around Anamaduwa.

🌟 C # Basics: Variables and Data Types 🌟Hey CodeGurls! πŸ‘©β€πŸ’» Ready to dive deeper into C #? Today, we’re going to explore ...
27/06/2024

🌟 C # Basics: Variables and Data Types 🌟

Hey CodeGurls! πŸ‘©β€πŸ’» Ready to dive deeper into C #? Today, we’re going to explore the basics of variables and data types. Understanding these concepts is essential for building more complex programs.

πŸ“š What are Variables?
Variables are like containers that hold data. Each variable has a specific type that determines what kind of data it can store.

Example Program:
Here’s a simple program that uses different types of variables:

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
using System;

namespace VariableDemo
{
class Program
{
static void Main(string[] args)
{
int age = 25;
double height = 5.9;
char grade = 'A';
string name = "Lakshi";
bool isStudent = true;

Console.WriteLine("Name: " + name);
Console.WriteLine("Age: " + age);
Console.WriteLine("Height: " + height);
Console.WriteLine("Grade: " + grade);
Console.WriteLine("Is Student: " + isStudent);
}
}
}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Breaking it Down:

>>>int age = 25; - Declares an integer variable named age and assigns it a value of 25.
>>>double height = 5.9; - Declares a double variable named height and assigns it a value of 5.9.
>>>char grade = 'A'; - Declares a char variable named grade and assigns it the character 'A'.
>>>string name = "Lakshi"; - Declares a string variable named name and assigns it the value "Lakshi".
>>>bool isStudent = true; - Declares a boolean variable named isStudent and assigns it the value true.

Your Turn!
Try creating a similar program with your own details and see the output. Share your progress and any questions in the comments below! πŸ“©

Keep coding and stay curious! 🌟

🌟 Welcome to CodeGurl Chronicles! 🌟Hey CodeGurls! πŸ‘©β€πŸ’» Today, we're diving into the world of C # (C-Sharp), a powerful an...
27/06/2024

🌟 Welcome to CodeGurl Chronicles! 🌟

Hey CodeGurls! πŸ‘©β€πŸ’» Today, we're diving into the world of C # (C-Sharp), a powerful and versatile programming language used for developing a wide range of applications. Whether you're a beginner or looking to brush up on your skills, this post is for you!

πŸ“š Introduction to C #: Hello World!

Let's start with the classic "Hello, World!" program, which is often the first step in learning any programming language. This simple program prints "Hello, World!" to the console.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

using System;

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

πŸ” Breaking it Down:

>>>using System; -
This line imports the System namespace, which contains fundamental classes and base classes that define commonly used data types, events, and more.

>>>namespace HelloWorld -
Namespaces are used to organize your code. Here, we're creating a namespace called HelloWorld.

>>>class Program -
In C #, every piece of code must be inside a class. We're defining a class named Program.

>>>static void Main(string[] args) -
This is the Main method, which is the entry point of any C # program. The static keyword means that the method belongs to the class itself, not instances of the class. void indicates that this method doesn't return a value. The string[] args parameter is used for command-line arguments.

>>>Console.WriteLine("Hello, World!"); -
This line prints "Hello, World!" to the console. Console is a class in the System namespace, and WriteLine is a method that outputs the specified string to the console.

πŸŽ‰ Your Turn!

Now it's your turn to try this out! Open your favorite C # development environment (like Visual Studio), create a new project, and type in the code above. Run the program and see your first C # output!

Stay tuned for more coding tips and tutorials. Let's keep coding and growing together! πŸ’ͺ

Address

Anamaduwa

Website

Alerts

Be the first to know and let us send you an email when CodeGurl Chronicles posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Share