Activity 1 Read and explain the contents of C# Classes (Use comments) C# is an o
ID: 2247073 • Letter: A
Question
Activity 1 Read and explain the contents of C# Classes (Use comments) C# is an object-oriented language very similar to Java. Classes are the fundamental organizing blocks for code. Projects typically contain one to many C# classes On Visual Studio you can create two files that contain C# classes for the WindowsUI project . Program . Forml.cs To view the Program c class code, from Solution Explorer right click Program.ss and select Type below code 1. using System 2. using 3.using Sxstematin 4. using 6. namespace Windowsut static class Program 9 10. IThe main entry point for the appTication I 12 13. 14 15. 16 17 static void Main App EnablevisualstylesO; (fa 1se) 18 19 20 21. Application Run (new FormlO); Notes . The using directive allows one to shorten a reference to a class The Main method (note the capital M) is always the starting point in a C# windows application Application is a class defined in the .net frameworkExplanation / Answer
In General main method is the program.cs and put the logical code is in Form1.cs
program.cs with comments
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
/// Main Method is the starting point in a c# window application
[STAThread]
static void Main()
{
//It is a static method allow to set visual style with your .net control
Application.EnableVisualStyles();
//It uses GDI+ for rendring text in Forms.
Application.SetCompatibleTextRenderingDefault(false);
//From Main we calls for the creation of Form1. The code for Form1 is in the Form1.cs file
Application.Run(new Form1());
}
}
}
form1.cs with comments
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
/*
InitializeComponent is a method automatically written for you by the Form Designer
when you create/change your forms.
Every Forms file (e.g. Form1.cs) has a designer file (e.g. Form1.designer.cs) that
contains the InitializeComponent method, the override of the generic Form.Dispose,
and the declaration of all of your User Interface objects like buttons, textboxes
and labels.
The InitializeComponent method contains the code that initialize the user interface
objects with the values provided by you (the programmer) using the Property Grid of
the form designer. Also, you will find here, the plumbing required to link the controls
and form events to the specific event handlers you write to respond to the user actions.
*/
InitializeComponent();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.