Posts

Showing posts from May, 2024

Record

 // See https://aka.ms/new-console-template for more information Console.WriteLine("Hello, World!"); var std = new Student("Sabir", 21); Console.WriteLine("Name=" + std.Name); //std.Name = "Tejas"; var std2 = std with { Name = "Tejas", age = 22 }; Console.WriteLine("Name=" + std.Name); Console.WriteLine("Name=" + std2.Name); public record Student(string Name, int age);

get Set

Image
 

inheritance, get set

 using System; using System.Collections.Generic; using System.Text; namespace Inhereitance {     //Dad     class BaseClass     {         private int creditCard = 1234;//{get;set;}         public void PrintNumber()         {             Console.WriteLine("OldPin Credit Card=" + creditCard);         }         public int Sabir()         {             return creditCard;         }         public int getSetCredit        {             get {return creditCard; }             set{creditCard = value;}             }         public void ChangePin(int newpin)         {           ...

Class, Constructor

 using System; using System.Collections.Generic; using System.Text; namespace ConsoleApp2 {      class Demo     {         public Demo()         {             Console.WriteLine("Constructor");             Sum();         }         public Demo(String name)         {             Console.WriteLine("Name=" + name);         }                  //Destructor De Alocate memory          ~Demo()         {             Console.WriteLine("Destructor");         }         public int number = 10;        public void Sum()        {             Co...

Method Function

 using System; using System.Collections.Generic; using System.Net.Http; using System.Text; namespace ConsoleApp2 {         class Program     {        struct Student         {            public String name;            public int age;         };         int a=12;         enum Days { Sun, Mon, tue, Wed, thu, Fri, Sat };        static  void Main(string[] args)         {             Test1();             Test2("sabir",12);//call                  Console.WriteLine("Sum=" + addition());             Console.WriteLine("Mul=" + mul(12,2));         }         //1. Without return without par...

Method

 using System; using System.Collections.Generic; using System.Net.Http; namespace ConsoleApp2 {         class Program     {        struct Student         {            public String name;            public int age;         };             int a=12;         enum Days { Sun, Mon, tue, Wed, thu, Fri, Sat };        static  void Main(string[] args)         {             Program obj = new Program();             obj.Test1();             String name = "Computer";             obj.Test2("sabir",12);//call         }         //1. Without return without parameter         v...

enum

 using System; using System.Collections.Generic; using System.Net.Http; namespace ConsoleApp2 {         class Program     {        struct Student         {            public String name;            public int age;         };         enum Days { Sun, Mon, tue, Wed, thu, Fri, Sat };         static void Main(string[] args)         {             int n =(int) Days.Mon;             Console.WriteLine("Index=" + n);         }         } }

String and struct

using System ; using System.Collections.Generic ; namespace ConsoleApp2 { class Program { struct Student { public String name ; public int age ; } ; static void Main(string[] args) { Student student = new Student() ; student . name = "Sabir" ; student . age = 13 ; Console . WriteLine ( "Name=" + student . name + " Age=" + student . age ) ; String str = @ "Compuuter \" ; string str2 = "computer" ; var num1 = 10 ; var s = "abc" ; int count = 0 ; for (int i = 0 ; i < str .Length ; i ++) { if ( str [ i ]== 'a' || str [ i ]== 'e' || str [ i ] == 'i' || str [ i ] == 'o' || str [ i ] == 'u' ) { count ++ ; } } Console . WriteLine ( "Total vowls=" + count ) ; } } }