CodeGurl Chronicles
Contact information, map and directions, contact form, opening hours, services, ratings, photos, videos and announcements from CodeGurl Chronicles, Marketing Agency, Anamaduwa.
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! π
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! πͺ
Click here to claim your Sponsored Listing.
Category
Culinary Team
Attire
Website
Address
Anamaduwa