Featured

    Featured Posts

    Social Icons

Loading...
infolinks

Overview Of .NET Framework Architecture

The .NET is a very large Framework that supports building and running the various applications and XML Web services. It is hard to decide whether to code something or use an existing component of the framework.

  • The .NET Framework consists of the common language runtime(CLR) and the .NET Framework Class Library. The common language runtime is the heart of the .NET Framework.
  • The common language runtime performs various operations such as managing memory, thread execution, code execution, code safety verification, compilation, etc. 
  • Components of a .NET architecture


Common Language Specification:

The Common Language Specification (CLS) is a set of types(data types) that may be used in external calls in code that is intended to be portable.Microsoft has defined CLS which specifies guidelines for languages to follow so that it can communicate with other .NET languages in a seamless manner. In simple words, CLS is a document that says how computer programs are converted into bytecode. When several languages use the same bytecode, different parts of a program can be written in different languages. So Common Language Specification is used in  the .net framework. To interact with other objects regardless of the language they were coded in, objects must expose to callers only those features that are common to all the languages they must exchange information with. Microsoft unite all different languages into one umbrella and CLS is one. Most of the types defined in the .NET Framework class library are able to work with CLS. However, some types in the class library have one or more members that are not able to work with CLS. These members allow support for language features that are not in the CLS.


Framework class library
The .NET Framework class library is a collection of  classes, interfaces, and value types that provide access to system functionality. It is the base on which .NET built in applications, components, and controls are rely on. The "System" is the root namespace of all the namespaces in .Net Framework.

Common Language Runtime
Common Language Runtime (CLR) provides an environment to run all the .Net Programs. The code which runs under the CLR is called as Managed Code. Programmers need not to manage the memory if the programs are running under the CLR as it provides memory management and thread management.
Logically, when a program needs memory, CLR allocates the memory for scope and de-allocates the memory if the life time expires.
Language Compilers (e.g. C#, VB.Net, J#) will convert the Code/Program to Microsoft Intermediate Language (MSIL/IL) intern this will be converted to Machine Code by CLR.


Common Type System
Identifies the types supported by the common language runtime.

Visual Studio
Visual Studio is a hugecollection of tools and services to help you create a wide variety of applications, both for the Microsoft platform and beyond. Visual Studio also connects all of your projects, teams.

               

How to Compile and Run programs from a Command Prompt

  • You can compile the program by using the command line with out using the Visual Studio Integrated Development Environment (IDE).
  • To compile and run from a command prompt
  • Type the code with the help of any text editor, and then save the file as a text file with .cs extension. Now save the file as Welcome.cs. Every C# source code file uses the extension .cs.
  • Perform the following steps to open a command-prompt window:
  • Open the Start menu, expand the folder for the current version of Visual Studio, open the shortcut menu for Visual Studio Tools, and then choose Developer Command Prompt for VS2012/VS2010.
  • A Developer Command Prompt window appears.
  • Enable command-line builds from a standard Command Prompt window.
  • See How to: Set Environment Variables using "path".
  • In the command-prompt window, navigate to the folder that contains your Welcome.cs file.
  • Enter the following command to compile Welcome.cs.
  • csc Welcome.cs
  • If your program has no compilation errors, an executable file that is named Welcome.exe is created.
  • In the command-prompt window, enter the following command to run the program:
  • Welcome

How to Run C# programs in Visual Studio

You can test your program a number of ways. First, though, it has to be built. This is when everything is checked to see if there are any errors. Try this:
  • From the View menu at the top of Visual Studio, click Output. You'll see a window appear at the bottom. (In VS 2010, if you can't see an Output option, click the Tools menu. From the Tools menu, select Settings > Expert Settings. The Output menu item should then appear on the View menu.)
  • From the Build menu at the top of Visual Studio, click Build Solution
  • You should see the following report:
The Output window in C# NET
The final line is this:
Build: 1 succeeded or up-to-date, 0 failed, 0 skipped
That's telling you that everything is OK.
Now try this:
  • Delete the semicolon from the end of your line of code
  • Click Build > Build Solution again
  • Examine the output window (version 2012 will just show and error and won't build)
This time, you should see these two lines at the end of the report:
Compile complete -- 1 errors, 0 warnings
Build: 0 succeeded or up-to-date, 1 failed, 0 skipped
So that it couldn't build your solution because there was 1 error.
Put the semicolon back at the end of the line. Now click Debug from the menu at the top of Visual Studio. From the Debug menu, select Start Debugging.
You should see a black DOS window appear and then disappear. Your program has run successfully!
To actually see your line of text, click Debug > Start Without Debugging. You should now see this:
Your C# Programme
And that's the output! Now have a look at the Solution Explorer on the right. Because the project has been built, you'll see more files under Debug:
The Debug item in the Solution Explorer
However, in Visual Studio 2010 you'll see a Release folder. Expand this:
The build files in C# 2010
We now have a ConsoleApp1.exe. The exe file is an executable program, and it appears in the bin/debug folder. Switch back to Windows Explorer, if you still have it open. You'll see the exe file there. (In the Release folder in visual studio 2010, but in the Debug folder in earlier versions):
The files in the bin/debug folder
If you want to create a desktop shortcut to this exe file. When you double click the desktop shortcut, the program will run.

Swapping of Two Numbers Using Various Logics



Method-1
---------

Swapping of two numbers using third variable


import java.util.Scanner;
 
class SwapNumbers
{
   public static void main(String args[])
   {
      int x, y, temp;
      System.out.println("Enter x and y");
      Scanner in = new Scanner(System.in);
 
      x = in.nextInt();
      y = in.nextInt();
 
      System.out.println("Before Swapping\nx = "+x+"\ny = "+y);
 
      temp = x;
      x = y;
      y = temp;
 
      System.out.println("After Swapping\nx = "+x+"\ny = "+y);
   }
}



Method-2
-----------

Swapping of two numbers without using third variable

import java.util.Scanner;
 
class SwapNumbers
{
   public static void main(String args[])
   {
      int x, y;
      System.out.println("Enter x and y");
      Scanner in = new Scanner(System.in);
 
      x = in.nextInt();
      y = in.nextInt();
 
      System.out.println("Before Swapping\nx = "+x+"\ny = "+y);
 
      x = x + y;
      y = x - y;
      x = x - y;
 
      System.out.println("After Swapping\nx = "+x+"\ny = "+y);
   }
}


Mehod-3
------------

Swapping of two numbers using XOR Operator


int a = 2; //0010 in binary
int b = 4; //0100 in binary
      
= a^b; //now a is 6 and b is 4
= a^b; //now a is 6 but b is 2 (original value of a)
= a^b; //now a is 4 and b is 2, numbers are swapped
      
Method-4
------------

Swapping Of Two Numbers Using Multiplication and division operators

int a = 6;
int b = 3;
//swapping value of two numbers without using temp variable using multiplication and division
= a*b; //now a is 18 and b is 3
= a/b; //now a is 18 but b is 6 (original value of a)
= a/b; //now a is 3 and b is 6, numbers are swapped
Method-5
---------
Swapping of two numbers in a single statement
int a = 10; int b = 20; a = ( a + b ) - ( b = a ); Method-6
------------
Swapping of two numbers in a single statement
int a = 10; int b = 20;
a = b + 0 * (b = a);
Method-6
-----------

import java.io.*;
class swap{
        public static void main(String args[]) throws IOException{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            System.out.print("Enter 1st no: ");
            int x=Integer.parseInt(br.readLine());
            System.out.print("Enter 2nd no: ");
            int y=Integer.parseInt(br.readLine());
            System.out.println("\nNumbers Before Swapping:");
            System.out.println("x = "+x);
            System.out.println("y = "+y);
            //Swapping Method 2
            x = x^y;
            y = x^y;
            x = x^y;
            System.out.println("\nNumbers After Swapping:");
            System.out.println("x = "+x);
            System.out.println("y = "+y);
        }
}

About Us

Powered by Blogger.
© Copyright aspdotnet-rk
Back To Top