Beginning with Visual Studio

Beginning with Visual Studio

In this instructional exercise we'll begin taking a gander at the C# programming language and beginning with Visual Studio with an example DBMS project for fifth sem VTU students. C# is a mainstream programming language that can be utilized to make programs for tablets, telephones, web servers, and work areas. The Syntax of C# is like Java, C++, and JavaScript and is one of numerous dialects that can be utilized for .NET programming. In case you're prepared to find out about programming in C#, Microsoft makes accessible an awesome network release of their ground-breaking Visual Studio IDE. We'll utilize Visual Studio Community during these next few C# instructional exercises.

Download And Install Visual Studio

By using the link above, you’ll be able to install Visual Studio Community. The start page looks like this.
microsoft visual studio community start page


The .NET Framework

With Visual Studio presently introduced, the. NET Framework is additionally introduced since it is a piece of the Visual Studio establishment.Composing applications in C# with Visual Studio influences the. NET Framework. This implies applications can exploit a wide range of administrations that the structure gives. This incorporates things like sparing data to a database, perusing data from a XML document, just as arrangement, organize tasks, and all the fundamental center highlights that almost every application needs. C# can accordingly be utilized to assemble business applications, games, web applications, and applications that sudden spike in demand for tablets or cell phones. The .NET Framework accomplishes it's work by method of the Common Language Runtime and the Framework Class Library.


The CLR manages your application

  • Memory the executives 

  • Language freedom
  • Working framework and equipment freedom 


CLR and FCS for dot net


System class library

  • A library of usefulness to assemble applications 

microsoft framework class library


Working With C#

C# is a mainstream language and ideal to work with in the event that you know about C, C++, Java, and JavaScript. How about we utilize Visual Studio to make our first C# program,so as to really observe the aftereffects of the code you compose, you should order it first. How about we perceive how to make a too straightforward support application in Visual Studio now. You can choose File->New->Project->Visual C#-> Console App(.NET Framework). 

Visual Studio Console Application

Visual Studio will set up some standard code for us which resembles this. 


Solution Explorer In Visual Studio

When the new venture is made, we likewise observe the arrangement traveler. The Solution Explorer window arranges the entirety of the ventures code and just as different tasks. In the screen capture underneath, we see that WelcomeToCSharp is featured which speaks to the present task. Within that venture we have three organizers. 

Those are binobj and Properties. There is likewise an App.config record, a Program.cs document, and a Visual C# Project File named WelcomeToCSharp.csproj. 

Visual Studio Solution Explorer


Namespaces In C#

Notice at the highest point of the Program.cs document that there are a few lines of code we probably won't be acquainted with.

namespaces

For the present we can erase those namespaces with the goal that our Program.cs resembles this. .

Now, we are utilizing our own namespace, which is WelcomeToCSharp. So the class of Program is truly something like WelcomeToCSharp.Program. How about we work something out to the support at that point! 


Building And Running Your C# Application

How about we put this program in to activity. To see the aftereffect of our code up until this point, we can tap on Debug, and afterward Start Without Debugging. 

Quite Sweet! We got our first C# reassure application to run. Visual Studio consequently aggregated the source code and propelled the program in another reassure window. Visual Studio consequently included the "Press any key to proceed . . ." discourse to cause the comfort window to leave. In the event that this wasn't given, you'd see an order window streak on the screen for a second and that is about it. The program can likewise be run from the order line by composing the name of the executable, WelcomeToCSharp.exe. 

C:\Users\user\source\repos\WelcomeToCSharp\WelcomeToCSharp\bin\Debug>WelcomeToCSharp.exe
Welcome To C#!

Passing A Parameter To Our Program

So as to alter our first C# Program somewhat more, how about we include support for going in a Parameter. Here is the way we can do that. 

With the refreshed source code, we'll have to assemble the program so as to refresh the executable record for the task. This should be possible by tapping on Build->Build Solution or with the console alternate route of Ctrl+Shift=B. 
visual studio build solution

Now, we can run the program again from the order line and go in a string parameter like so. Note that while determining the name of the program, you can exclude the .exe from the finish of the document when running it. 

C:\Users\user\source\repos\WelcomeToCSharp\WelcomeToCSharp\bin\Debug>WelcomeToCSharp Tom
Welcome To C#, Tom!

We can run it again and go in an alternate string parameter just to see it in real life. 

C:\Users\user\source\repos\WelcomeToCSharp\WelcomeToCSharp\bin\Debug>WelcomeToCSharp Friend
Welcome To C#, Friend!

Preventing Runtime Errors

We have our program tolerating a parameter with the goal that it shows a custom message. What occurs on the off chance that we don't pass that contention when running the program? Indeed, how about we see. 

C:\Users\user\source\repos\WelcomeToCSharp\WelcomeToCSharp\bin\Debug>WelcomeToCSharp

Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
at WelcomeToCSharp.Program.Main(String[] args) in C:\Users\user\source\repos\WelcomeToCSharp\WelcomeToCSharp\Program.cs:line 9

windows checking for solution to problem

OOPS!. We get a frightful mistake message, and the program crashes. We can adjust the program so that if a contention isn't given at runtime, we won't understand that Index was beyond the cluster blunder message. Here is the refreshed code. 

Now,when we run the program it won't crash in the event that we don't give a contention. Beneath we run the program once with no contention, on the other hand with a contention. The program currently has rationale as a straightforward if/else articulation with the goal that it can carry on diversely relying upon what was passed to it. 

C:\Users\user\source\repos\WelcomeToCSharp\WelcomeToCSharp\bin\Debug>WelcomeToCSharp
Welcome To C#, Friend!

C:\Users\user\source\repos\WelcomeToCSharp\WelcomeToCSharp\bin\Debug>WelcomeToCSharp Partner
Welcome To C#, Partner!

Using Console.ReadLine

Another methodology we could take to the program is to incite the client for data while the program is running. We can do this with the Console.ReadLine strategy. 

Now when the program runs, we are incited to enter a few information. The program doesn't push ahead until we do as such.

A simple DMBS project for 5th SEM VTU STUDENTS

You can go through the codes copy it or type it and execute.Click on the link below to get access to the source code.



Post a Comment

1 Comments