Introduction to Integrated Development Environments
Introduction to Integrated Development Environments
Introduction to Solutions
Introduction to Microsoft Visual Studio
The most fundamental part of a C# application is code. You can write that code using any text editor such as Notepad, compile that code, and execute it to get a "physical" application. That is a way an application is created manually but it can take too much effort. A solution to work a litte faster is to use an integrated development environment or IDE. Probably the most popular IDE you can use is Microsoft Visual Studio.
Besides assisting you in writing code, Microsoft Visual Studio provides many other valuable options and tools to write and manage code.
When it comes to .NET Framework applications, a solution is an object in which one or more applications exist or are/were created. This means that you want to create an application, you start from a solution. So far, such a solution was automatically created for us. Otherwise, you can create a solution either from the command prompt or from Microsoft Visual Studio.
Practical Learning: Creating a Solution
The Starting Foundation of a Solution
A solution is primarily a text file, or more precisely an XML file. When you start a solution, whether you are working from the Command Prompt or you are using the Configure Your New Project dialog box, you must specify a folder (location) in which the solution will be created. When you finalize the creation, the compiler creates a file that has the name you indicated for the solution, and the file receives the ".slnx" extension (in the previous versions of the .NET Framework, the solution had the extension .sln). This is a simple XML file with only one element:
<Solution />
Normally, you should not (or ever) be concerned with this file, and you should never modify it. The compiler modifies when there is a certain change in the solution. You can open that file using any text editor, including Notepad, to see its contents; but there is hardly any reason you should manually modify that file.
In the folder (or directory) you specified for a solution, the compiler creates a sub-folder named ".vs". That sub-folder contains a sub-folder that uses the name you specified for the solution, plus a period and "slnx" as if it were an extension. The .snlx folder in turn has a sub-folder named "v18". Of course, "v18" stands for version. That v18 folder contains a JSON filer that serves as a configuration file. That file is named DocumentLayout.json. Here is an example of such a file:
{
"Version": 1,
"WorkspaceRootPath": "F:\\Programs\\Consoles\\AltairEstates\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": -1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:3:0:{e8b06f52-6d01-11d2-aa7d-00c04f990343}"
},
{
"$type": "Bookmark",
"Name": "ST:2:0:{e8b06f52-6d01-11d2-aa7d-00c04f990343}"
},
{
"$type": "Bookmark",
"Name": "ST:1:0:{e8b06f52-6d01-11d2-aa7d-00c04f990343}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{e5c86464-96be-4d7c-9a8b-abcb3bbf5f92}"
}
]
}
]
}
]
}
As you can see, the top section of the DocumentLayout.json file contains an element named WorkspaceRootPath. The value of that element is the location of the solution. Below the WorkspaceRootPath element is an element named Documents. If you create a blank solution, that Documents element would not have any child. The other parts of the document assist the compiler. As mentioned for the ".slnx" file, you can open JSON configuration with any text editor, including Notepad, to see its contents; but there is no real reason you should manually modify that file. The compiler takes care of it and modifies it when necessary.
Opening a Solution
If you have a solution that was proviously created but is not currently used, if you want to use it, you can open it. You have various options. If a solution was previously used, to open it, on the main menu of Microsoft Visual Studio, click File. Position the mouse on Recent Projects and Solutions. Click the desired option that has the .slnx (or .sln) extension.
If you want to open a solution based on its folder/location, on the main menu of Microsoft Visual Studio, click File, position the mouse on Open, and click Project/Solution. Locate the folder where the solution exists. Select the desired option that has the .slnx (or .sln) extension.
The shortcut to open a solution is Ctrl + Shift + O.
Closing a Solution
After using a solution, you can close it. The primary or classic way is to close Microsoft Visual Studio, which would automaticall close the solution. As another option, if you open another solution, the solution that was being used would be closed automatically. Sometimes, you want to stop using a solution with you want to keep Microsoft Visual Studio opened. In this case, you can simply close the solution. To close a solution, on the main menu of Microsoft Visual Studio, click File and click Close Solution.
Introduction to Projects
A project is a group of files and resources that produce an application. This means that, if you want to have an application, start from a project.
Introduction to Microsoft Visual Studio
As we have seen so far, it is very easy to create a project. All you have to do is to start Microsoft Visual Studio or display the Add New Project dialog box, then select Create A New Project. In the Configure Your New Project dialog box, specify a name for the project and continue.
If you had already created a solution, you can add a project to it.
Practical Learning: Creating a Project
Console.WriteLine("=====================================================================================================");
Console.WriteLine(" Eastern Properties Rentals");
Console.WriteLine("-----------------------------------------------------------------------------------------------------");
Console.WriteLine(" Altair Estates");
Console.WriteLine("=====================================================================================================");
Console.WriteLine("Prop # | Property Type | Address | City | State | ZIP-Code | Beds | Baths");
Console.WriteLine("=======|===============|========================|===============|=========|==========|======|========");
Console.WriteLine("770686 | Single Family | 4288 Lucow Drive | Rockville | MD | 20856 | 5 | 3.5");
Console.WriteLine("-------|---------------|------------------------|---------------|---------|----------|------|--------");
Console.WriteLine("250351 | Townhouse | 719 Beanson Road | Arlington | VA | 22201 | 4 | 3.5");
Console.WriteLine("-------|---------------|------------------------|---------------|---------|----------|------|--------");
Console.WriteLine("264649 | Condominium | 6662 16th Street NW | Washington | DC | 20012 | 1 | 1");
Console.WriteLine("-------|---------------|------------------------|---------------|---------|----------|------|--------");
Console.WriteLine("975700 | Single Family | 39 Anesta Court | Gettysburg | PA | 17325 | 3 | 2.5");
Console.WriteLine("-------|---------------|------------------------|---------------|---------|----------|------|--------");
Console.WriteLine("575370 | Condominium | 10574 Spring Floor Rd | Hinesville | GA | 31313 | 2 | 2");
Console.WriteLine("-------|---------------|------------------------|---------------|---------|----------|------|--------");
Console.WriteLine("747575 | Townhouse | 228 South Gather Str | Blanchard | OK | 73010 | 4 | 3.5");
Console.WriteLine("-------|---------------|------------------------|---------------|---------|----------|------|--------");
Console.WriteLine("375705 | Single Family | 8604 Bridge Stone Ave | Brecken Ridge | CO | 80824 | 4 | 4.5");
Console.WriteLine("-------|---------------|------------------------|---------------|---------|----------|------|--------");
Console.WriteLine("886868 | Condominium | 2644 Swanson Drive | Charleston | WV | 25301 | 3 | 2");
Console.WriteLine("-------|---------------|------------------------|---------------|---------|----------|------|--------");
Console.WriteLine("694708 | Single Family | 508 North Harrison Str | Papillion | NE | 68046 | 4 | 2.5");
Console.WriteLine("=====================================================================================================");The Projects of a Solution
In .NET programming, a solution is referred to as a container. As a result, a solution can contain many projects, as many as you want. In the previous section, we saw how to add a new projec to an existing solution. In the same way, you can keep adding projects to a solution. One of the advantages of a solution is that it can contain projects of different computer languages. After adding a project, you can manage it according to its type. This means that you can add to a projects any file that can be managed in that type of project.
Practical Learning: Adding Projects to a Solution
let firstName : string = "Emmanuel"
let lastName : string = "Reasons"
let jobTitle : string = "Accounts Manager"
let hSalary : float = 27.86
let monday : float = 9.5
let tuesday : float = 8
let wednesday : float = 10.5
let thursday : float = 9
let friday : float = 8.5
let timeWorked = monday + tuesday + wednesday + thursday + friday
let mutable regTime = timeWorked
let mutable overtime = 0.00
let mutable regPay = hSalary * timeWorked
let mutable overPay = 0.00
if timeWorked > 40.00 then
regTime <- 40.00
overtime <- timeWorked - 40.00
regPay <- hSalary * 40.00
overPay <- hSalary * 1.50 * overtime
let netPay = regPay + overPay;
printfn "===================================================="
printfn "Payroll Evaluation"
printfn "===================================================="
printfn "Employee Information"
printfn "----------------------------------------------------"
printfn "Full Name: %s %s" firstName lastName
printfn "Account Manager: %s" jobTitle
printfn "Hourly Salary: %0.2f" hSalary
printfn "===================================================="
printfn "Time Worked Summary"
printfn "--------+---------+-----------+----------+----------"
printfn " Monday | Tuesday | Wednesday | Thursday | Friday"
printfn "--------+---------+-----------+----------+----------"
printfn "%6.2f | %6.2f | %7.2f | %7.2f | %6.2f"
monday tuesday wednesday thursday friday
printfn "========+=========+===========+==========+=========="
printfn " Pay Summary"
printfn "----------------------------------------------------"
printfn " Time Pay"
printfn "----------------------------------------------------"
printfn " Regular:%8.2f %9.2f" regTime regPay
printfn "----------------------------------------------------"
printfn " Overtime:%7.2f %9.2f" overtime overPay
printfn "===================================================="
printfn " Net Pay:%18.2f" netPay
printfn "===================================================="Module Program
Sub Main(args As String())
Dim cost
Dim type
Dim make
Dim model
Dim period
Dim bookValue
Dim salvageValue
Dim estimatedLife
Dim depreciationRate
Dim yearlyDepreciation
period = 1
Console.WriteLine("Machines Depreciation")
Console.WriteLine("=======================================================================")
Console.WriteLine("Enter the required values")
Console.WriteLine("-----------------------------------------------------------------------")
Console.Write("Type of Machine: ")
type = Console.ReadLine()
Console.Write("Manufacturer: ")
make = Console.ReadLine()
Console.Write("Model: ")
model = Console.ReadLine()
Console.Write("Machine Cost: ")
cost = Console.ReadLine()
Console.Write("Salvage Value: ")
salvageValue = CDbl(Console.ReadLine())
Console.Write("Estimated Life: ")
estimatedLife = CInt(Console.ReadLine())
depreciationRate = 100.0# / estimatedLife
yearlyDepreciation = SLN(cost, salvageValue, estimatedLife)
bookValue = cost
Console.WriteLine("=======================================================================")
Console.WriteLine("Machine/Device: {0} {1} {2}", make, model, type)
Console.WriteLine("=======================================================================")
Console.WriteLine("Depreciation Schedule")
Console.WriteLine("=======================================================================")
Console.Write(" Depreciation" & vbTab & " Yearly" & vbTab & vbTab & vbTab & "Accumulated" & vbCrLf)
Console.Write("Year" & vbTab & "Rate" & vbTab & vbTab & "Depreciation" & vbTab & "Book Value " & vbTab & "Depreciation" & vbCrLf)
Console.WriteLine("=======================================================================")
Do
Console.WriteLine(" " & period & vbTab & FormatNumber(depreciationRate, 2) & "%" & vbTab & vbTab &
FormatNumber(yearlyDepreciation) & vbTab & vbTab &
FormatNumber(Format(bookValue - (yearlyDepreciation * period), "#")) & vbTab &
FormatNumber(yearlyDepreciation * period))
Console.WriteLine("-----------------------------------------------------------------------")
period = period + 1
Loop Until period = estimatedLife + 1
End Sub
End ModuleExecuting a Project
Introduction
In previous lessons, we saw how to execute a project to see its results. As a matter of fact, you can execute a project using the main menu of Microsoft Visual Studio, the Solution Explorer, or a shortcut.
Practical Learning: Executing a Project
=====================================================================================================
Eastern Properties Rentals
-----------------------------------------------------------------------------------------------------
Altair Estates
=====================================================================================================
Prop # | Property Type | Address | City | State | ZIP-Code | Beds | Baths
=======|===============|========================|===============|=========|==========|======|========
770686 | Single Family | 4288 Lucow Drive | Rockville | MD | 20856 | 5 | 3.5
-------|---------------|------------------------|---------------|---------|----------|------|--------
250351 | Townhouse | 719 Beanson Road | Arlington | VA | 22201 | 4 | 3.5
-------|---------------|------------------------|---------------|---------|----------|------|--------
264649 | Condominium | 6662 16th Street NW | Washington | DC | 20012 | 1 | 1
-------|---------------|------------------------|---------------|---------|----------|------|--------
975700 | Single Family | 39 Anesta Court | Gettysburg | PA | 17325 | 3 | 2.5
-------|---------------|------------------------|---------------|---------|----------|------|--------
575370 | Condominium | 10574 Spring Floor Rd | Hinesville | GA | 31313 | 2 | 2
-------|---------------|------------------------|---------------|---------|----------|------|--------
747575 | Townhouse | 228 South Gather Str | Blanchard | OK | 73010 | 4 | 3.5
-------|---------------|------------------------|---------------|---------|----------|------|--------
375705 | Single Family | 8604 Bridge Stone Ave | Brecken Ridge | CO | 80824 | 4 | 4.5
-------|---------------|------------------------|---------------|---------|----------|------|--------
886868 | Condominium | 2644 Swanson Drive | Charleston | WV | 25301 | 3 | 2
-------|---------------|------------------------|---------------|---------|----------|------|--------
694708 | Single Family | 508 North Harrison Str | Papillion | NE | 68046 | 4 | 2.5
=====================================================================================================
Press any key to close this window . . .
Return to your programming environmentThe Default Project of a Solution
In previous lessons, we saw how to create a project. The steps also automatically created a solution. This meant that, unlike as seen in the previous sections of this lesson, both the solution and the project were created at the same time. On the other hand, in our introductions in this lesson, we saw how to first create a solution before separately adding the projects. You can also start by creation a project and solution, then add one or more solutions.
If you have a solution that contains more than one project, one of the projects is referred to as the default. In the Solution Explorer, the name of the default is in bold characters. If you you a solution that contains many projects, if you simply execute the application, the default project would execute. If you want to execute another project, one solution is to designate that project as the default one.
Practical Learning: Setting the Default Project of a Solution
====================================================
Payroll Evaluation
====================================================
Employee Information
----------------------------------------------------
Full Name: Emmanuel Reasons
Account Manager: Accounts Manager
Hourly Salary: 27.86
====================================================
Time Worked Summary
--------+---------+-----------+----------+----------
Monday | Tuesday | Wednesday | Thursday | Friday
--------+---------+-----------+----------+----------
9.50 | 8.00 | 10.50 | 9.00 | 8.50
========+=========+===========+==========+==========
Pay Summary
----------------------------------------------------
Time Pay
----------------------------------------------------
Regular: 40.00 1114.40
----------------------------------------------------
Overtime: 5.50 229.84
====================================================
Net Pay: 1344.25
====================================================
Press any key to close this window . . .Executing a Specific Project
If you have a solution that contains more than one project, at any time, you can execute any project of your choice. This is done from the Solution Explorer.
Practical Learning: Executing a Specific Project
Machines Depreciation
=======================================================================
Enter the required values
-----------------------------------------------------------------------
Type of Machine: Business Printer
Manufacturer: Xerox
Model: AltaLink C8130
Machine Cost: 6500
Salvage Value: 1000
Estimated Life: 8
=======================================================================
Machine/Device: Xerox AltaLink C8130 Business Printer
=======================================================================
Depreciation Schedule
=======================================================================
Depreciation Yearly Accumulated
Year Rate Depreciation Book Value Depreciation
=======================================================================
1 12.50% 687.50 5,813.00 687.50
-----------------------------------------------------------------------
2 12.50% 687.50 5,125.00 1,375.00
-----------------------------------------------------------------------
3 12.50% 687.50 4,438.00 2,062.50
-----------------------------------------------------------------------
4 12.50% 687.50 3,750.00 2,750.00
-----------------------------------------------------------------------
5 12.50% 687.50 3,063.00 3,437.50
-----------------------------------------------------------------------
6 12.50% 687.50 2,375.00 4,125.00
-----------------------------------------------------------------------
7 12.50% 687.50 1,688.00 4,812.50
-----------------------------------------------------------------------
8 12.50% 687.50 1,000.00 5,500.00
-----------------------------------------------------------------------
Press any key to close this window . . .Introduction to the Internal Workings of a Solution and its Projects
A File for a Project
When you create or add a project, Microsoft Visual Studio (actually the C# compiler) automatically creates an XML file for that project. The file has the extension "csproj". You can open that file using any text editor, including Notepad. Here is an example:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
This is a simple configuration file that assists the compiler. There is hardly any reason you will want to manually change this file.
A File for a Solution
As seen in our introduction to solutions, remember that when you create a solution, the compiler automatically generates an XML file (".slnx") that contains a simple element named Solution. Here is an example:
<Solution />
If you add a project to a solution, if you build or execute the project, the compiler creates and adds an element for that project in the ".slnx" file. Here is an example:
<Solution>
<Project Path="EasternRentals/EasternRentals.csproj" />
</Solution>
If you create or start a project in Microsoft Visual Studio, the solution is created and a project is automatically added to the solution. In this case, an XML element for the project is automally created in the ".slnx" file.
In the same way, every time you add a project to a solution (and build or execute the solution), the compiler updates the ".slnx" file. Here is an example:
<Solution>
<Project Path="EasternRentals/EasternRentals.csproj" />
<Project Path="MachinesDepreciations/MachinesDepreciations.vbproj" Id="e13fe758-0d33-4783-9f66-19fea5cf26d6" />
<Project Path="PayrollEvaluation/PayrollEvaluation.fsproj" Id="72e69615-d5ca-479c-b158-a599082be429" />
</Solution>
Also, if you create or add a project, the compiler opens the DocumentLayout.json file and creates a child for the Documents element. That child is created for the project. That child element is made of two sub-elements named AbsoluteMoniker and RelativeMoniker respectively. That Documents-child is created for each project. This means that that Documents-child contains a combination of AbsoluteMoniker and RelativeMoniker sub-elements for each project.
Practical Learning: Executing an Application
|
|
|||
| Previous | Copyright © 2001-2026, FunctionX | Sunday 14 December 2025, 14:27 | Next |
|
|
|||