Skip to main content

Posts

Showing posts with the label C#

.NET Introduction,What is .NET? Scope of .NET

.NET is a common technology  and it support multiple framework that is used to create a different type of application using multiple programming languages . . NET is not a programming language , It provides a platform to compile and execute many programming languages including C#, VB, J#, F#, C++, etc. .NET was developed by Microsoft to enhance the VB6.VB language was platform-dependent and it is only for a desktop application. .NET was created to develop a desktop and web-based application that can easily work on intranet (LAN) and internet-based applications. .NET means network enable technology. now .NET supports 90+ programming languages using a single framework hence .NET is also called multilanguage technology. Type of application of .NET:- 1) Standalone application or Desktop application:-  This type of application will be installed separately for each machine and it works individually for each PC. 1.1)  Windows Forms Application: -  for normal desktop applica...

What is C# and How to set path in C#

What is C# and How we set path in C#:- C# is the object-oriented programming language, which is used to create a . NET-based application. Every Windows machine has .NET Framework by Default no need to install it because Windows User Interface Part has been developed by .NET If we want to compile and execute C# Program Under Command Prompt Then First we open cmd and Copy Default Path  C:\Windows\Microsoft.NET\Framework\v4.0.30319 and Paste into the command prompt using the following command. Set path=C:\Windows\Microsoft.NET\Framework\v4.0.30319 If we want to set a permanent path under windows. Right Click on MyComputer|This PC ---->  Properties  ---> Advanced System Setting--->Environment Variable ----> Variable name:-   path Variable value:-  C:\Windows\Microsoft.NET\Framework\v4.0.30319 Click on OK, OK then OK, PATH will be Set

Create First Program of C#?

Create First Program of C#:- 1 Install Visual Studio or .NET Framework  (windows has .NET Framework by default) 2 Open notepad and write Program  using System;  //namespace (it contain a set of classes and methods logically)   class Classname   {      public static void main()     {      }   }    3   Save this file using .cs extension in any driver c:/,d:,etc 4   Compile this file using Command Prompt      CSC  Filename     (CSC means C-Sharp compiler) 5   Execute this file       Filename.exe                           

Assignment of C#:-

Assignment of C#:- 1)  WAP to reverse three-digit number without using Loop 2)  WAP  to calculate electricity bill where unit price and total consumption will be entered by the user. 3)  WAP to create a salary calculator where basic, ta, da, comm,pf, and noofleave will be entered by the users. using System; class SalaryCalc {     public static void Main()     {           float basic=12000,ta=200,da=200,comm=300,pf=500,nl=2,asal=200;           float tsal,gsal;           gsal=basic+ta+da+comm;           Console.WriteLine("Gross Salary Is {0}",gsal);           tsal=gsal-(gsal/30)*nl-asal-pf;           Console.WriteLine("Total Salary Is {0}",tsal);     } } 4)  WAP to calculate Area of Circle and Area of Triangle.  

Create Program in C# Without Using Visual Studio

Create a Program in C# Without Using Visual Studio:- 1)  Open Notepad and Create a C# Program for Simple Interest 2) Create Program using System; class SI {   public static void Main()   {       float p=12000,r=2.2F,t=2,si;       si= (p*r*t)/100;       Console.WriteLine("result is {0}",si);   } } 3)  Save this program using SI.cs 4)  Compile this program using csc FileName     csc SI.cs 5)  Execute this program using       SI.exe                                       

How to take input from USER'S in C#

How to take input from USER'S in C#:- To take input from User's in C# We will use Console.ReadLine(),   It will return data in String pattern which can be easily typecast into different datatype. C# provide parse() and Convert class to data type conversion where parse() throw ArgumentNullException if data is Null but Convert Class provides no any exception if assigned String value is Null. using System; class Add {    static void Main()    {        int a,b,c;        Console.WriteLine("Enter First Number");        a = Convert.ToInt32(null);               Console.WriteLine("Enter Second Number");         b = int.Parse(Console.ReadLine());          c=a+b;        Console.WriteLine("Result is {0}",c);    } } User's Input based on Different Datatype:- 1)    int a =...

Data-type Concept in C#

Datatype Concept in C#:- It is used to provide a pattern of data and the size of data in memory. The data type will be used into variable, constant, and method declaration. Data type under variable:- Datatype variablename=value         int x=10 Data type under constant:- const Datatype constantname=value    const int y=100 C# has two different types of Datatype 1)  Primitive:-   It Supports all datatype of C and CPP languages. int     --------->  4byte   (C# has Int16, Int32, Int64) float  ----------> 4byte, 8 bytes ( float size depends on ox base 32 and 64)  char  -----------> 2byte string  --------->  Based on no of chars boolean  ------>  It returns a true or false value using 1 and 0 2)  Derived Datatype:-     This type of Datatype was specially Created by .NET Framework that is common for all .NET Supported programming lan...

What is boxing and unboxing concept in c#

what are the boxing and unboxing concept in c#:- Boxing means to convert primitive type data to object type for example if we convert int, char, float to Object then it is called boxing.it is also called implicit conversion in c# because it will automatically convert the value. Unboxing means to convert Object type data to Value type for example if we convert  Object to int, char, float then it is called Unboxing.it is also called explicit conversion in c# because it will manually convert the value. using System; class Boxing {     public static void Main()     {           object o;           int b=100,c;           o=b;   //boxing           Console.WriteLine(o);           c=(int)o; //Unboxing           Console.WriteLine(c);               } }  ...

Operator in C#

The operator in C#:- It is used to perform an operation using operand,  operand can be variable, constant, and literals. C# support all operators of C and C++. c=a+b // here a and b is the variable type operand 10+20  // here 10 and 20 are the literals Type of Operator:- 1) Unary Operator:-   It will work using a single operand 1.1.1)  Increment|Decrement   :-              ++ (increment) ,--(decrement)            Post  :-     ++,--  a++,a--  (first perform other operation then increment or decrements)             Pre  :-      ++,--, ++a,--a  (First increment or decrement then perform other operation) the best example of post and pre-increment and decrement in C# programming languages. using System; class Inc {     public static void Main()     {       ...

Conditional Statement in C-Sharp, If--else Statement in C#

Conditional Statement in C-Sharp:- It is used to solve a condition-based program, It provides a separate section for true conditions and false conditions. Ternary operator can contain only a single statement on the true section and false section.  that's why we mostly prefer if...else statements to solve condition based program. Condition Statements have two different statements first is IF and another one is Else Syntax of IF Statements:- if(condition)   {           Statements; } It will execute when the condition will be true. Syntax of  ELSE Statements:- else { } It will not execute separately, It is a dependent statement under if, when IF condition will be false then Else statement will be executed. Combination of else and IF:- else if(condition) { } It is a combined statement of Else and IF  that will work similarly to else but we can provide the condition, it is also a dependent statement under the...

Switch Statement in C#

Switch Statement in C#:- It is used to create a choice-based or option-based program, It provides multiple case statements to represent multiple-choice, we can select a particular statement under switch then it will match from respective case statements. switch(option) {    case option-value:      Statement;      break;    case option-value:      Statement;      break;     case option-value:      Statement;      break;     default:      Statement;      break; } We will check option==optionvalue then that statement will be executed. class SwitchProgram     {         static void Main()         {             char ch;             Console.WriteLine("Enter Char");       ...