Skip to main content

 

 Structure of C#


using System;             // Gives access to Console and other basic features 
namespace MyFirstProgram      // Defines a namespace
{
    class Program             // Main class of the program
    {
        static void Main(string[] args)  // Main method, starting point
        {
            Console.WriteLine("Hello, World!"); // Prints output to screen
        }
    }
}

  •  using System;

This line allows your program to use predefined classes and functions in the System namespace.
For example,
Console.WriteLine() is part of System.

It's like importing built-in tools so you can use them in your code.

  •  namespace MyFirstProgram

A namespace is like a container for your classes. It helps organize code and avoid naming conflicts when your program gets bigger.

 Think of it like putting files in folders.

  •  class Program

All C# code must be written inside a class. Here, the class is named Program.
A class is a blueprint that contains data (variables) and actions (methods or functions).

It's like a box that holds your actual code logic.

  •  static void Main(string[] args)

This is the entry point of the C# program. When you run the program, execution starts from this method.

·         static: You don’t need to create an object to run this method.

·         void: This means the method doesn’t return any value.

·         Main: The name of the method where the program starts.

·         string[] args: This is used to take command-line arguments (optional for now).

 It tells the computer: "Start here!"

  •  Console.WriteLine("Hello, World!");

This line displays text on the screen.

·         Console: A built-in class for input/output.

·         WriteLine(): A method that prints the given text and moves to a new line.

This is the actual action of your program.

Comments

Popular posts from this blog

Function of OS 1. Process Management The operating system helps in running many programs at the same time. It keeps track of each running program (called a process), decides which one should run next, and stops or starts them as needed. It makes sure that all the programs get a fair chance to use the CPU.   2. Memory Management The OS manages the computer's memory (RAM). It decides which program will use how much memory and keeps track of it. When a program is closed, it frees up the memory so that other programs can use it. This helps the computer run smoothly without crashing.   3. File System Management The operating system helps us to create, save, open, and delete files. It organizes files in folders and keeps them safe. It also controls who can open or edit a file to protect our data.   4. Device Management The OS controls all the input and output devices like the keyboard, mouse, printer, and monitor. It tells the devices what to do and makes su...

UNIT 3 Array in C#

  Array in C# An array is a collection of variables of the same data type , stored in contiguous memory locations , and accessed using a common name and index . Each item in an array is called an element , and the index of arrays in C# starts from 0 .     Key Points About Arrays in C#: 1.       Elements are stored in contiguous memory locations. 2.       Index starts from 0. So, for an array of size 5, valid indexes are 0 to 4. 3.       Arrays are reference types and are allocated on the heap. 4.       C# array is an object of base type System.Array . 5.       Array elements can be of any type , including another array (array of arrays). 6.       Jagged array (array of arrays) elements are reference types and are initialized to null . 7.       Arrays can be single-dimensi...

Unit 2 Java

Data Types A data type defines the kind of data a variable can store, the operations that can be performed on it, and the amount of memory allocated. Java Primitive Data Types Data Type Size Range (Approx.) Example Byte 1 byte -128 to 127 byte a = 100; short 2 bytes -32,768 to 32,767 short s = 1000; Int 4 bytes -2,147,483,648 to 2,147,483,647 int num = 50000; Long 8 bytes -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 long l = 100000L; float 4 bytes ~6–7 decimal digits float f = 5.75f; double 8 bytes ~15 decimal digits double d = 19.99; Char 2 bytes Single Unicode character char c = 'A'; boolean 1 bit* tru...