CSharp forms application 4

CSharp forms application 4

classForm

This is our simple form form comprised of a button and two labels and textboxes.

>





In our CSharp forms application 4 , we will address the classification, which is the basic aspect of object oriented programming.

When you characterize a class, you characterize an outline for an information sort. This does not really characterize any information, but rather it does characterize what the class name implies. That is, the thing that an object of the class comprises of and what operations can be performed on that protest. Items are cases of a class. The routines and variables that constitute a class are called members from the class.

Properties uncover fields. Fields ought to (quite often) be kept private to a class and got to by means of get and set properties. Properties give a level of reflection permitting you to change the fields while not influencing the outer way they are gotten to by the things that utilization your class.The fields may be an alternate to variables.

A method is a code hinder that contains a progression of statements. A program causes the statement to be executed by calling the method and indicating any obliged method arguments. In C#, each executed statement is performed in the connection of a method.
Let’s see them in form application:

using System;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Classes
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
myClass obj = new myClass();
txtInitial.Text = obj.Str;

}

public class myClass
{

// Private field str
private string str=”Initial”;

//Public property Str

public string Str
{

get
{

return str;

}

set
{
str = value;

}

}

public string changeValue(string myString)
{
myClass obj = new myClass();
obj.Str = myString;
return obj.Str;

}

}

private void button1_Click(object sender, EventArgs e)
{
myClass obj = new myClass();

string str = obj.changeValue(“Changed”);
txtChanged.Text = str;
}
}
}

Now, run the application and click the button and see:

classForm2

Syed Adeel Ahmed
Analyst, Programmer, Educationist and Blogger at Technofranchise
Computer Systems Engineer from Sir Syed University Of Engineering & Technology.I am passionate about all types of programming.
Syed Adeel Ahmed on FacebookSyed Adeel Ahmed on GoogleSyed Adeel Ahmed on InstagramSyed Adeel Ahmed on Twitter

Published by

Syed Adeel Ahmed

Computer Systems Engineer from Sir Syed University Of Engineering & Technology.I am passionate about all types of programming.

Leave a Reply