C# LinkLabel Control
Hey Everyone! Hope you all are doing great and enjoying your lives. My job is to keep you updated with useful information that helps you excel in your relevant field. Today, I am going to give the details on the
C# Linklabel Control. This control allows you to display a hyperlink. It exhibits all the properties given by C# Label Control but it is explicitly used for displaying useful information on the hyperlink. I'll try to cover each and every aspect related to C# Linklabel Control so you don't need to go anywhere for finding the information regarding this control. Let's hop on the board and dive in the details of this control and explore its properties step by step.
C# LinkLabel Control
- C# Linklabel Control is used to display hyperlink to provide useful information.
- In order to create C# Linklabel control, open the windows form application and go to Toolbar appearing on the left side.
- Find the Linklabel control, drag and drop it over the Form.
- You can play with it and move it around over the Form with the help of mouse.
- There is another way of creating the Linklabel control. Just double click on the Linklabel control, it will automatically place the Linklabel control on the Form.
Linklabel Control Properties
- In order to set the Linklabel control properties, just right click on the Linklabel control and go to properties.
- Properties window will appear on the right side of the windows form application.
- Linklabel control comes with different useful properties including, name, autosize, text, size, font, fontcolor, back color etc. Let's discuss them one by one. Following window will appear as click on the properties.
Name and Text Properties
- Name property defines the specific name of the control that is used to access it in the code. In the figure above, Linklabel control name is linkLabel1.
- Similarly, text property is used to display the descriptive text on the link. You can go to properties and change the name manually or you can change it in a code as well.
- Following code can be used to change the text of the Linklabel Control.
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
linkLabel1.Text = "this is label one";
}
BackColor, BorderStyle, ForeColor Properties
- BackColor property is used to change the background color of the linklable control.
- BorderStyle is used to give linklable control a specific border style around the link text. It comes with two border styles including FixedSingle, Fixed 3D.
- ForeColor is used to change the forecolor of the linklabel control.
Font, AutoSize and TextAlign Properties
- Font property shows the font style of the text that can be used in linklabel control. When you go to properties, and click on Font property, it shows different font styles, size and
- AutoSize property is used to change the size of the linklable control. By default the value of AutoSize property is true, when it is true, you can not change the size of the linklable. When it is set to false, you can change the size of linklabel.
- Similarly, TextAlign property is used to align the linklabel text in the linklable control. It comes with 9 different options to align the text at different place on the linklabel control.
Image and ImageAlign Properties
- Image property is used to set the background of the linklabel control as an image.
- Similarly, ImganAlign property is used to align the image on the background of the linklabel control.
Color Properties
- LinkColor property shows the color of the link in linklabel control.
- LinkVisited property comes with two states true and false. When it is false, color of the link won't be changed once the link is visited. When it is set true, the color of the link will change once the link is visited.
- VisitedLinkColor property shows the color of the visited link. By default purple color is set to the VisitedLinkColor property.
- ActiveLinkColor property represents the color when you put the cursor on the link and click. The color appears before you fully clicked the link is ActiveLinkColor.
Example 1
- We are going to build a program which will allow the linklabel to open some website.
- In order to do this, open the windows form application and drag and drop the linklabel from the Toolbar to Form.
- Double click on the linklabel, following figure will appear.
- Now add "using System.Diagnostics" in the code just like the shown in the figure below.
- Now add following code in your application. When you run the application, and click on the link, it will allow the link to open the google website.
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("www.google.com");
}
That's all for today. Thanks for reading the article. We always love when you keep coming back for what we have to offer. If you have any question you can ask me in the comment section below. I'd love to help you according to best of my expertise. Stay Tuned!
C# ListView Control
Hi Guys! Hope you are doing great. Our mission is to give you valuable knowledge related to your field so you keep coming back for what we have to offer. Today, I am going to unlock the details on the
C# ListView Control. It displays useful information about list of items by using various views available in the control. You can also have a look at LinkLabel and DateTimePicker that I have discussed previously. I'll try to cover every aspect related to ListView Control so you get a clear idea about this control and you don't need to go anywhere else for finding the information regarding this control. Let's get started.
C# ListView Control
- C# ListView Control is used to display list of items by using various views available in the control.
- It is very useful in developing the applications where you want the data to be arranged in the form of list.
- Creating a ListView Control in Windows Form Application is very easy.
- Simply open the windows form application and drag the listview control from the ToolBar to Form.
- You can also create it by double clicking the listview control on the ToolBar, it will automatically place the listview control on the Form. Once you create the listview control it will look like the figure below.
- You can change its location with the help of mouse.
- Once you click on the little arrow available on the top right corner, it will appear like the figure below.
- Here you can see the ListView Tasks from where you can add items, columns, groups in the list and can change the view of the list that comes with different view options including largeicon, smallicon, list, title.
ListView Properties
- LlistView control comes with lots of different properties which you can modify manually.
- In order to open the properties window, right click on the listview control on the Form and go to properties windows.
- Once you open the properties windows, it will appear like the figure below which comes with different available properties.
Name
- Go to properties window and find property "Name" which specifies the unique name of the control which is used to access it in the the main code.
Location and Size Properties
- Location property represents the starting point of the listview control on the main Form. In other words, it represents the coordinates of the upper left corner of the control relative to the upper left corner of the container.
- Size property defines the size of listview control on the main Form. You can put the width and length on the size property or you can increase the size of the control by clicking the lower right corner of the control and expanding it towards right side.
ForeColor and BackColor Propeties
- ForeColor represents the forecolor of the listview control on the main Form.
- BackColor property represents the background color of the listview control.
- You can change both forecolor and backcolor manually by simply going to the properties window by right clicking on the listview control or you can change them by the help of code. Following lines can be used to change fore and back color in the code.
listView1.BackColor = Color.Brown;
listView1.ForeColor = Color.Blue;
View, GridLines, FullRowSelect Properties
- View property comes with 5 options to view the data on the list. FullRowSelect Property allows the cursor to select all add appearing in single row.
- Similarly, if you set GridProperty property as true, it will put the grid lines on the listview control. Following lines can be used to access these properties in the code.
listView1.View = View.Details;
listView1.GridLines = true;
listView1.FullRowSelect = true;
Items and CheckBoxes Properties
- Items property is very useful in this control that allows you to add items one by one. You can add items manually through this control but better way is using proper code to add items in the listview control.
- You can use these lines to add items in the code
ListViewItem lv1 = new ListViewItem("Adnan Aqeel");
lv1.SubItems.Add("123 main street");
lv1.SubItems.Add("25");
listView1.Items.Add(lv1);
- First we create three columns naming name, address and age and set the view to details. Then we add above lines in the main code by double clicking the listview control.
- CheckBoxes property allows you to add checkbox in the listed item. By default checkboxes property is false, set this property as true in order to add checkboxes of items in the control.
LabelEdit and HoverSelection Properties
- LabelEdit is very handy as it allows you to change the text of the items available in the list.
- Set this property as true in order to change the text of the items manually.
- However, you can also change text of the items dynamically in the code.
- HoverSelection property is used to make the item selected when someone hover the mouse on it.
- Set this property true in order to make the item selected over hovering the mouse over it.
HotTracking and Alignment Properties
- HotTracking property allows you to underline the text of the item and make it prominent when someone hovers mouse over the item in the list. Set this property as true in order to make this property useful.
- Alignment property is very useful that allows you to align the items in the list properly. It comes with four options including default, left, top, SnapToGird.
Columns and Groups Properties
- Columns property is very important property of the control that allows you to add the columns in the list. This property becomes handy when you are using the Details view of the control.
- Groups property allows you to distinguish the classes of items distinctively.
How to Add Columns in the ListView Control
Example 1
- Let's create a code for which we add items on the list step by step by the add button, then we remove the selected data from the delete button and then clear all data from the clear button in the windows form application.
- When we add one panel, three buttons, three textboxes, three labels and one listview on the main form, it will look like a figure below.
- Following is the code to run this application to add items in the list step by step and remove it or clear it completely.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication20
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnAddRecord_Click(object sender, EventArgs e)
{
ListViewItem lv1 = new ListViewItem(txtStudentName.Text);
lv1.SubItems.Add(txtFatherName.Text);
lv1.SubItems.Add(txtRegistrationNo.Text);
lvRecord.Items.Add(lv1);
}
private void btnDeleteSelected_Click(object sender, EventArgs e)
{
lvRecord.Items.Remove(lvRecord.SelectedItems[0]);
}
private void btnClearAll_Click(object sender, EventArgs e)
{
lvRecord.Items.Clear();
}
}
}
- Following figure shows the code in Visual Studio.
- Here's a short video in which I have shown How to use C# ListView Control:
That's all for today. I hope you have enjoyed the article and got to know the features of listview control. We always love when you visit our website to resolve your issues related to engineering. However, if still you feel any doubt or have any question you can ask me in the comment section below. I'd love to help you according to best of my expertise. Stay Tuned!
C# DateTimePicker Control
Hi Guys! We always aspire to make yourself equipped with useful information so you can excel and grow in your relevant field. Today, I am going to uncover the details on
C# DateTimePicker Control. It allows you to select date and time and show it in specific format. It is extremely useful when you develop any application where you want date of birth of user in a specified format or where you want to display date and time explicitly. I'll try to discuss each and every feature of
C# DateTimePicker Control, so you don't have to go anywhere else for finding the information regarding this specific control. Let's get started.
C# DateTimePicker Control
- C# DateTimePicker Control allows you to select date and time and show in specified format.
- It is very useful in developing the applications where you want user data in the form of date of birth.
- It behaves like an interface where user can change the date and time information.
- The display of this control contains fields that are defined by the format string of the control.
- Creating a DateTimePicker control is very easy. Open your windows form application and drag and drop the DateTimePicker control from Toolbar that is appeared on the left side to your Form1.
- Or simply double click the DateTimePicker control, it will automatically be placed on your Form1 displayed on the screen.
- You can play with it and change its location in the given space of Form1 or resize it with the help of mouse.
- When you run the application, monthly calendar will be displayed on the screen, where you can see date, month year and day.
- You can select any date of your own choice. It will appear like the figure below.
- You can also change the format of the DateTimePicker control in the code. As you double click the Form1, following figure will appear.
- Simply put the following code under the Form1_Load function if you want to appear the date in this format i.e year/month/date.
private void Form1_Load(object sender, EventArgs e)
{
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "yyyy/MM/dd";
}
Similarly, if you want the date to be appeared in this format i.e date/month/year. You can use the following code.
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "dd/MM/yyyy";
- You can make your own custom time format by doing minor changing in code.
- Similarly, if you want the format where you want to show both date and time, you can use the following code.
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "yyyy/MM/dd hh:mm:ss";
DateTimePicker Properties
- Setting the properties of DateTimePicker control is very easy. In order to open the properties of the DateTimePicker control just right click on the DateTimePicker control and select properties.
- Properties window will appear on the right side of the screen and it will appear like the figure below.
Name
- Name property defines the specific name of the DateTimePicker control which is user to access the control in the main code.
- In the figure above name of the DateTimePicker control is set as dateTimePicker1.
Location and Size Properties
- Location property defines the location of the DateTimePicker control with respect to x axis and y axis on the Form1.
- You can set values of your own choice by simply putting the values in the Location property box or you can move around the DateTimePicker control on the Form with the help of mouse.
- Size property defines the size of the DateTimePicker control. You can simply put the values of your own choice in the size property box or you can increase the size with the mouse by simply putting the cursor of the mouse of the right border of the control and expanding it towards right side or lower side.
Font and Format Properties
- Font property defines the text style of the DateTimePicker control.
- Go to the properties window and select the Font property.
- It will show font size with different font style. You can choose any style of your own choice.
- Similarly you can change the format of the DateTimePicker control. This control comes with four format including long, short, time and custom.
ShowChekBox and ShowUpDown Properties
- ShowCheckBox property allows the the control to be editable without using the calendar.
- This can be achieved by setting the ShowCheckBox as true.
- ShowUpDown property in the property window allows you to change the date and time by showing up and down value where you can increase and decrease the value of date and time.
- Set the ShowUpDown as true and modify the date and time of your own choice.
- When you set both ShowCheckBox and ShowUpDown as true and run the application, following figure will appear.
Value
- Value property of DateTimePicker control is widely used in C#.
- It stores the current value of date and current in the control.
Example 1
Now we build a code where it will show the date and time in the specific format and when button is clicked, then code will show the current date and time stored in the DateTimePicker control. Check following code to understand this process.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "yyyy/MM/dd hh:mm:ss";
}
private void button1_Click(object sender, EventArgs e)
{
DateTime iDate;
iDate = dateTimePicker1.Value;
MessageBox.Show("Current date is " + iDate);
}
}
}
- When you run the application, and click the button, output will show in the following form.
How to Show Null Value in DateTimePicker Control
- It is important to note that we can not use null value in DateTimePicker control by default because it is a value type like int, bool, and float and it returns some value.
- You can make DateTimePicker control empty or it will show null value.
- First drag and drop one DateTimePicker control on the Form. Then right click on the DateTimePicker control and go to properties. Properties will appear on the right side of the screen.
- In the property window find the property "Format" and set it as Custom. Then find the property "CustomFormat" and simply add a space in the box. After you run the application it will show the empty box of DateTimePicker control.
- Or you can show DateTimePicker control empty by the following code.
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
dateTimePicker1.Format = DateTimePickerFormat.Custom;
if (dateTimePicker1.Checked == false)
{
dateTimePicker1.CustomFormat = " ";
}
else
{
dateTimePicker1.CustomFormat = "yyyy/MM/dd hh:mm:ss";
}
- Before applying this code first we set ShowCheckBox as true in the property window of the DateTimePicker control. Then we apply this code.
- We are playing a trick here, we first set the format of the DateTimePicker as custom, then set the format text of the DateTimePicker as black space.
- This will do the trick and will set the DateTimePicker as blank when the box will be unchecked otherwise it will return some value.
- When you run this code output will appear like the figure below when ShowCheckBox is unchecked.
That's all for today. I have tried my best to give you valuable information in simple steps so you can get an easy grip on C# sharp language. However, if still you feel skeptical or have any doubt you can ask me in the comment section below. I'll go extra mile to help you solve your questions and queries as soon as possible. Stay Tuned!
C# CheckBox Control
Hi Guys! I hope you are doing great and having fun with your lives. Today, I am going to unlock the details on the
C# CheckBox Control. A CheckBox control is used to select the single or multiple options from the given list of options. I'll give you a brief detail how you can create CheckBox in the Windows form application. Also, I will discuss the properties and methods used in CheckBox control. You can also have a look at
C# Button Control. which we discussed in previous article. Let's hop on the board and dive in the details of CheckBox control.
C# CheckBox Control
- C# CheckBox Control is used to select the single or multiple options from the given list of options.
- In order to create CheckBox in design time, drag the CheckBox from the ToolBox located at the left side and drop it to the form1 main screen.
- As you create the CheckBox, it will look like the figure below.
- You can also create CheckBox in design time by simply double clicking on the CheckBox control.
- As you double click on the CheckBox control, it will create a CheckBox on the form1.
CheckBox Properties
- As you drag and drop the CheckBox on Form1, next step is to check the properties of the CheckBox.
- You can check the properties of the CheckBox by right clicking on the CheckBox then go to properties option.
- Properties Window will look like below figure.
Location and Size Properties
- Location property defines the starting point of check box with respect to x axis and y axis on the form1.
- You can simply click on the CheckBox and change the location of the box.
- Similarly, size property defines the size of the CheckBox control.
BackColor, BackgroundImage, ForeColor Properties
- BackColor is used to define the background color of the CheckBox.
- You can simply go to BackColor property in the property menu of the CheckBox and choose the color of your own choice.
- BackgroundImage is used to select the background image of the CheckBox.
- Go to the BackgroundImage property and choose the image of your own choice.
- ForeColor defines the foreground color of the checkbox.
- In the first figure forecolor of the checkBox1 is black.
- You can go to the ForeColor property of the properties list and choose the color of your own choice.
Name, Font, Appearance Properties
- Name defines the unique name of the CheckBox control which is used to access the CheckBox control in the main code.
- In the first figure, name of the CheckBox is checkBox1.
- Font property is used to select the font of the text the appears on the CheckBox control. As you click on the Font property, you can choose the desired font from the available list of font styles.
- From appearance property, you can select between two appearance options i.e. normal or button. Normal checkbox will look like as shown in the first figure. While button option will appear like the figure below.
Text, TextAlign and CheckAlign Properties
- Text property of the CheckBox is used to change the text that appears on the CheckBox.
- In the first figure, text that appears on the CheckBox is checkBox1.
- The TextAlign property defines the text alignment of the text that can be from TopLeft to BottomRight.
- CheckAlign property represents the alignment of the check mark in the CheckBox control.
- In the first figure the alignment of the check mark is MiddleLeft.
CheckState and Checked Properties
- CheckState define the state of the checkbox which can be checked, unchecked and intermediate.
- CheckBox control will be checked if check mark on the CheckBox control is checked and it will be unchecked if the check mark of the CheckBox control is unchecked.
- CheckState is directly connected with the Checked property of the CheckBox control.
- If CheckState is Checked or Intermediate then Checked property will be true and if CheckState is Unchecked then Checked property will be false.
Example 1
- This example will clearly elaborate the use of check box.
- Simply open the windows form application in C#.
- Then drag and drop a button and four check boxes from the Toolbar to Form1.
- Change the name of each check box by right clicking on each checkbox separately and then go to the properties of the checkbox and find "text" property. And change the name of the button to "Combine" by similar process.
- In next step, change the Checked property of both L and T checkboxes and set it to true.
- As you set the Checked property to true it will automatically change the CheckState and set it to as Checked.
- Now double click on the combine button it will take you to the window like below.
- In the figure above button1_Click function which will be get called when the button will be clicked in Windows form application.
- Now copy and paste the code below in your button function.
private void button1_Click(object sender, EventArgs e)
{
String last = "this is check box ";
if (checkBox1.CheckState == CheckState.Checked)
{
last += "L";
}
if (checkBox2.CheckState == CheckState.Checked)
{
last += "A";
}
if (checkBox3.CheckState == CheckState.Checked)
{
last += "S";
}
if (checkBox4.CheckState == CheckState.Checked)
{
last += "T";
}
MessageBox.Show(last);
}
- There are four condition of this code.
- If first condition will be true i.e. CheckState of the checkBox1 is checked and it will go to next step and call the word last with addition of "L" which is a string and is equal to "this is a check box".
- So when first condition will be true, output of the code will be shown like below.
When all four CheckBoxes are checked then it will show an output like below.
That's all for today. I hope you have got a clear idea about checkbox. However, if still you feel skeptical or have any doubt, you can ask me in the comment section below. I'll help you according to best of my expertise. Your suggestions and feedback will be highly appreciated. We always love when we are able to meet your needs and expectations. Stay tuned!
Introduction to C# Classes
Hi Everyone! Hope you all are doing great. We always love when you keep coming back for what we have to offer. Today, I am going to give you a
Introduction to C# Classes. We have already seen Introduction to Data Types in C# which includes boolean, integer, char and double. However, if you want to make complex custom type, you can make use of classes. I'll give you a brief introduction to classes so you don't have to go anywhere to find information regarding classes in C#. Let's hop on the board and dive in the details of classes.
Introduction to C# Classes
- Class in C# is referred as a blueprint of complex data type that describes the behavior and data of type.
- If you want to create complex custom type, we use class. What do I mean by complex custom type?
- Suppose you want to store a number 123, you can store it easily in an integer variable.
- However, if you want to store the customer's information, you can use classes like what kind of information customer has, what is his first and last name, his email ID, phone number and age etc.
- By using a built-in fields we can create a class.
- Fields of class define the class data and methods define the behavior of the class.
- When we create customer class, it not only contains the data, it can also do certain things like save the customer to the data base, print the customer full name etc.
- So, class has state and behavior, state is nothing but data and behavior is nothing but what the class is capable of doing.
How to Create a Class
In order to create a class we use a class keyword followed by the name of the class and members of class are enclosed by curly brackets. Let's look at an example which will make things clear.
Example 1
Following figure shows the complete explanation of classes.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Customer
{
string _firstName;
string _lastName;
public Customer (string FirstName, string LastName)
{
this._firstName = FirstName;
this._lastName = LastName;
}
public void PrintFullName()
{
Console.WriteLine("Full Name = {0}", this._firstName +" "+ this._lastName);
}
~Customer()
{
//clean up code
}
}
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Customer C1 = new Customer("Adnan", "Network");
C1.PrintFullName();
}
}
}
- In the above example first name and last name of the customer is stored in a string which represents the state of the class.
- To initialize these fields a class can also have an constructor.
- A constructor will have a same name as that of your class.
- We make constructor public which is an access modifier.
- Constructors are basically used to initialize the class fields.
- Then we pass two parameters into this constructor which are string FirstName and string LastName.
- Constructor doesn't return a value but it can take parameters.
- Then we use constructor to initialize these class fields i.e _firstname and _lastname.
- This field _firstname is equal to the parameter FirstName and the field _lastname is equal to the parameter LastName.
- Then we put "this" keyword before firstName and lastName which is used to define the instance of classes also referred as objects.
- So, basically we are using constructor to initialize the class fields with parameters that are passing into the constructor.
- In the next step we add a behavior which allows the class to do something.
- We want to print the full name of the customer. This is called the method of the class which tells the behavior of the class.
- So far, we have created constructor, two fields and a methods for the class.
- In the next step we call the destructor of the class.
- Destructor will have the same name as that of the class but it doesn't take parameters and doesn't have a return type.
- Usually in C# we don't require destructors.
- We use destructors to clean up the resources your class was holding on to during its life time.
- We don't need to call the destructors, they are automatically called by the garbage collector.
- In the next step we make use of class in our main method.
- In this step we create instance C1 of class Customer with using the keyword "new".
- This instance is also called the object of the class. Instances and Objects are used interchangeably.
- Then we call FirstName and LastName of the customer. When we put FirstName as Adnan, it will pass through the parameter (string FirstName) of the constructor. And put second name as Network that will pass through the parameter(string LastName) of the constructor.
- Constructors are called automatically when you create instance of class.
- Also, constructors are not mandatory to use, if you don't provide a constructor, .NET framework will automatically provide a default parameter less constructor.
- In the next step we print the full name of the customer.
Output
Output of the above program will be like below.
That's all for today. I hope you have got a clear idea about class, constructor and destructor used in C#. However, if still you feel any doubt or have any question you can ask me in the question below. I'll be happy to help you in this regard according to best of my expertise. Stay tuned!
Introduction to Data types in C#
Hey Guys! I hope you all are doing great. Today, I am going to give a detailed
Introduction to Data types in C#. It's our 3rd tutorial in C# series & it's a theoretical tutorial so you just need to read it once.
I'll try to cover every aspect related to Data types in C# so you get a clear picture of what are data types and why we need them? So, let's get started with Introduction to Data types in C#:
Introduction to Data types in C#
- Data Types in C# are used to inform the compiler about the type, size & nature of data that can be stored in a variable.
- Whenever we need to declare a variable, we need to inform the compiler about the data size & type of the variable.
- There are 3 types of data types available in C# programming, which are:
-
- Value Data Type
- Pointer Data Type
- Reference Data Type
- Here's a Flow Diagram of C# Data types for better understanding.
- Let's discuss these C# data types one by one in detail:
1. Value Data Types
- Value Data Type Variable is the simplest variable in C#, to which we can assign a value directly and they save this value on the stack, so it's not cleared by Garbage Collector.
- Each variable stores its data in a separate memory so we can't assign a single memory to multiple variables, although we can update their data quite easily.
- Value data types are further divided into two types, named:
- Predefined data types.
- User defined data types.
A. Predefined Value Data Types: These Value Data Types are predefined in C# i.e. bool, int, float, decimal, char etc.
- Bool: a short form of Boolean, contains two values i.e. true or false.
- Int: a short form of integer.
- Char: a short form of character, which is used to store alphabets.
- Float: is used to store a floating point number i.e. number with decimal values.
- Here's a table showing Memory Size & Range of these Data Types in C#:
B. User Defined Value Data Types: User can also create customized data types in C# using existing data types. i.e. structure or enumerations etc.
- Enumerations This value data type contains set of related named constants which are called as enumerator list. The "enum" is used to declare the word enumerations.
- Structure or struct is referred as a grouped list of variables that can be placed under one name in memory. It is same like a "Class" in the reference type.
Don't worry about these concepts, we will cover them on by one in our coming lectures.
2. Pointer Data Type
- The pointer, also called as indicator or locator, is a data type in C# that points towards the memory address of a data, we need to use ( * ) in its declaration.
- The pointer in C# can only hold the memory address of arrays and value types i.e. int, char, float etc.
- No conversion is allowed between pointer types and objects.
- However, conversion between two different pointer types is allowed, you can also convert between pointers and integral types.
- You can also point multiple pointers in same data type.
3. Reference Data Types
- Reference data types in C# don't consist of actual data, instead they point towards the reference to the data stored in a variable, it saves data in the heap.
- In reference data types, it's possible for two variable to reference to the same object.
- Reference Data Types are further divided into two types:
A. Predefined Reference Data Types: contain objects, strings etc.
- String is a sequence of finite characters which can contain spaces and number. Total number of characters in the string refers to the string length. i.e. "I need 20 dollars" is a string.
- Object is referred as a block of memory that executes according to the blueprint.
B. User Defined Reference Data Types: contain classes, interface, etc.
Nullable Data Types
- In C# data types, the most commonly used data types are Value Types & Reference Types. Pointer types are not used that much.
- In above discussion, we have seen that:
- Value Data Types: int, float, double, structs, enums etc.
- Reference Data Types: string, interface, class, delegates etc.
- By default, Reference data types are nullable datatypes i.e. we can assign null value to these datatypes.
- Let's say, if I want to initialize a string with null value, I need to use this code: string[ ] data = null;
- On the contrary, Value Data Types are non nullable by default in C# i.e. we can't initialize an integer with null value.
- But we can make a value data type nullable by using a ( ? ) sign in front of the datatype.
- int? i = null; It will work fine and won't create any error because now i has created a nullable integer.
Why we need nullable ?
- Let's say you are designing a sign up form and you want user to select the gender i.e. male or female.
- We can store this value in Boolean variable but what happens if the user doesn't select any value.
- That's where nullable comes in handy and in this third case where user hasn't selected any value, we can assign a null value to our Boolean variable.
That's all for today. I hope you have got a clear idea about data types in C# language. However, if still you feel skeptical or have any question, you can ask me in the comment section below. I'll try to resolve your query according to best of my expertise. Keep your feedback and suggestions coming, it will help us to augment the quality of our article and give you flawless work that resonates with your needs and expectations. Stay tuned!
Introduction to 2n3055
Hey Guys! Hope you all are doing great and having fun with your lives. I am back to feed your stomach with plenty of information so you can progress and grow in real life. Today, I am going to unlock the details on the
Introduction to 2n3055. It is a semiconductor
NPN (negative-positive-negative) power transistor which comes in TO-3 Casing.
I'll try to cover as many aspects possible related to this device so can get a brief overview about what it does and what are the applications it is used for. Let's get started.
Introduction to 2n3055
- The 2n3055 is a semiconductor NPN bipolar transistor which consists of three terminals called emitter, base, and collector.
- Unlike FETs(Field effect transistors) it is a current controlled device in which small current at the base side is used to control a large amount of current at the emitter and collector side.
- It is a bipolar device in which conduction is carried out by the movement of both charge carriers i.e electrons and holes.
- The measure of base current to control the large current at the emitter and collector side is used for amplification purpose.
- As 2n3055 is an NPN transistor, here base with positive with respect to emitter and P layer lies between the two layers of N doped semiconductor.
- P-doped layer of transistor acts like a base while other two N sides represent emitter and collector respectively.
- It comes with lots of electronic applications but mostly it is used for switching and amplification purpose.
- This NPN transistor can be configured with three configurations named as a common collector, common base, and common emitter configuration.
- It is important to note that it won't be useful for amplification purpose when it is configured with common emitter configuration as it encompasses a transition frequency of around 3 MHz that will allow the forward current gain drop to 1.
- The maximum collector-emitter voltage is highly dependent on the resistance intensity between emitter and base, provided by the external circuit.
- The 2n3055 is connected to a heat sink which widely effects the overall power dissipation by the transistor.
- However, in most of the application when an ambient temperature is high, low power dissipation is expected.
- This device is manufactured in such a way it can function with an efficient heat sink.
- However, proper care should be given in order to mount the device perfectly, otherwise, it can harm the device at large.
- Mica insulator is added in the manufacturing process that isolates the case of the transistor from the heat sink.
- This transistor is a bipolar current controlled device which is different than JFET which is a unipolar voltage controlled device.
2n3055 Pinout
2n3055 consists of three terminals which are given below.
1: Emitter
2: Base
3: Collector
Pinout of 2n3055 is given in the figure below.
- A small amount of base current is used to control the large current at the emitter and base side.
- Conduction is carried out when electrons emit from the emitter and are collected by the collector.
Circuit Diagram of 2n3055
The circuit symbol of 2n3055 is shown in the figure given below.
- As it is an NPN silicon transistor so it has positive base terminal and a negative emitter terminal.
- This transistor is a current controlled device where a small amount of current at the base side is used to handle a large amount of current at the emitter and collector side.
- The NPN and PNP transistor encompass same features with some exceptions i.e. Current will sink into the base side in case of PNP transistor while current from the base side will source to the transistor in case of NPN transistor.
- Emitter current is the sum of base and collector current.
- Transistor forward current gain can be found by dividing the collector current to the base current. It is also called beta current and is denoted by ß. Beta has no units as it is a ratio between two currents.
- Beta value is used for the amplification purpose. Beta value ranges between 20 to 1000, however, its standard value is 200.
- At positive base to collector voltage, the ratio between collector current to the emitter current is called current gain of the transistor and is denoted by alpha a.
- The value of alpha lies between 0.95 to 0.99, however, in most of the cases it is considered as 1.
Maximum Rating of 2n3055
Absolute maximum rating of 2n3055 are given below
- It dissipates power around 115 W when the case temperature is set to 25 degrees.
- It is a 60 V and 15 A device which comes with a base current of 7 A and forward current gain ranges between 20 to 70.
Applications
- It is widely used in lots of applications where amplification of the signal is required.
- It is used for switching purpose.
That's all for today. I hope you have got a clear idea about this NPN transistor. However, if you still feel any problem in understanding the concept of this NPN transistor, you can ask me in the comment section below. I'd love to help you in this regard. Thanks for reading the article. Stay Tuned!
Introduction to 2n7000
Hi Everyone! I hope you all are doing great. I am back to whet your appetite with daily dose of information and knowledge that puts you ahead from others and makes you stand out of the party. Today, I am going to give you the
Introduction to 2n7000. It is an enhancement type N-Channel MOSFET which is mostly used for low power switching applications. It comes with different current ratings and lead arrangement. I am going to give you a brief detail about this component, so you don't have to go any where else to find information regarding this device. Let's get started.
Introduction to 2n7000
- 2n7000 is a uni-polar N-Channel Enhancement mode MOSFET which comes with terminals called drain source and gate.
- In this transistor, the input voltage applied at the gate terminal is used to control the conductivity between source and drain.
- The conducting path between source and drain is called channel whose length can be controlled by the input voltage at the gate terminal.
- As it is an enhancement mode MOSFET, it is assumed as OFF i.e. it doesn't conduct under normal operating condition when Vgs=0. It will start conducting when some input voltage is applied at the gate terminal.
- 2n7000 is a 60 V device and comes in TO-92 enclosure. Sometimes, it is termed as FETlinton and it an N-Channel MOSFET, so here conduction is carried out by the movement of electron rather than holes.
- It is a voltage controlled device which is widely used in place of other BJT(Bipolar junction transistors).
- However, it has many advantages over BJTs, as it requires no biasing for gate i.e. gate draws no current however, we need small surge current in order to charge the capacitance at gate terminal.
- It comes with high impedance and insulated gate, sometimes it is referred as IGFET(Insulated Gate Field Effect Transistor).
- As gate draws no current so it doesn't need any current limiting resister at the input of the gate terminal. However, protection gate resistor is required for the 2n7000 when it is used for the circuits that come with external gate vulnerability.
2n7000 Pinout
2n7000 is a uni-polar voltage controlled device which consists of three terminals.
1: Source
2: Gate
3: Drain
- Gate is practically isolated from drain and source and it draws no current.
- There is an insulation layer that lies between the gate and the body of transistor.
Working of 2n7000
- In 2n7000, the conduction between source and drain is carried out by the movement of electrons.
- In this transistor, source and drain are made up of n-type material while its body and substrate is made up of p-type material.
- In 2n7000, gate is biased by applying the positive input voltage that will attract the electrons available in the p-type semiconductor substrate.
- The gate of this transistor is used composed of layer of poly-silicon.
- When we add Silicon dioxide on the layer of substrate it gives the typical metal oxide semiconductor construction.
- Silicon dioxide is a dielectric material so it will act as a capacitor where one of its electrodes will be replaced by the semiconductor.
- If we apply positive voltage at the MOS structure, it will alter the charge distribution in the semiconductor. With the addition of positive voltage, the holes present under the oxide layer will experience a force and allow the holes to move downward. The depletion region will be accumulated by the bound negative charges which are associated with acceptors atoms.
- The overdose of free electrons available in the p-type substrate increases the overall conductivity of channel, and constantly inverts the electrical properties of p-type substrate, allowing the substrate to change into n-type material.
- The positive voltage applied on the gate terminal control the movement of electrons. As we increase the positive change at the gate terminal the more it will attract the electron, hence resulting in widening the channel path between source and drain terminals. Thus, increasing the positive voltage at the gate terminal will increase the overall conductivity of the transistor.
- This N-Channel transistor is composed to reduce on state resistance and give efficient switching performance.
Maximum Rating 2n7000
Maximum rating of 2n7000 are given in the figure given below.
- Drain-Source voltage is 60 V while Drain current is 200 mA.
- Power dissipation is about 350 mW.
- If values are exceeded more than the given values, they can harm the device at large.
Difference between N-Channel MOSFET and BJT
- N-Channel MOSFET are unipolar devices and BJT are bipolar devices.
- BJT are current control devices while MOSFET are voltage controlled devices.
- In BJT, we need base current to control the large amount of current at emitter and collector. In MOSFET, no biasing is required at the gate side as it draws no current. However small initial current is needed to charge the capacitance of the transistor.
Applications
- 2n7000 is mostly used for low power switching applications.
- It is used as a driver for motors, relays and lamps.
- It is widely used in battery operated systems and solid state relays.
- High speed circuits use MOSFET 2n7000 as it requires no buffer.
That's all for today. I hope you have enjoyed the article. I always try my best to give you quality work that requires minimum effort from your side to digest this information completely. However, if still you need any kind of help, you can ask me in the comment section below, I'd love to help you in this regard. Thanks for reading the article. Stay Tuned!
Introduction to 2n4401
Hey Everyone! I hope you are doing great and having fun with your lives. I am back to give you a daily dose of information so you can grow and progress in your relevant field. Today, I am going to uncover the details on the
Introduction to 2n4401. It is an
NPN (negative-positive-negative) bipolar junction transistor (BJT) which is used for general purpose amplification and switching purpose. It consists of P doped semiconductor that exists between the two layers of N doped material.
I'll give you a brief detail about this transistor so you don't have to go anywhere for finding the information regarding this transistor. You can also check the
Introduction to 2n4402 which is a complementary PNP transistor of this NPN transistor. Let's get started.
Introduction to 2n4401
- 2n4401 is an NPN bipolar junction transistor which is used for general purpose amplification and switching purpose.
- It is called bipolar junction transistor because conduction is carried out by both charge carriers i.e electrons and holes, but majority charge carriers will be electrons.
- It mainly consists of three terminals called emitter, base, and collector.
- Small current present at the base side is used to control the large current at the emitter and conductor side.
- P layer of this transistor represents the base terminals while other two N layers represent emitter and collector respectively. Base is positive with respect to emitter.
- 2n4401 is actually a current control device where small current at the base side is used to control the large current at the emitter and collector side.
- When a positive voltage is applied at the base side, it gets biased and allows the current to flow from emitter to collector.
- The emitter emits the electrons which are then collected by the collector and base controls the number of electrons.
- A transistor is a combination of diodes joined back to back.
2n4401 Pinout
2n4401 is an NPN transistor which mainly consists of three terminals.
1: Emitter
2: Base
3: Collector
- Base side of this transistor is lightly doped while emitter side is heavily doped.
- When small current controls the large current at the emitter and collector, this process is used for amplification purpose.
Circuit Diagram of 2n4401
Circuit diagram of 2n4401 is shown in the figure below.
- The voltage at the collector side is more than the voltage at the base side.
- This transistor comes with three main configurations i.e common base configuration, common emitter configuration, and common collector configuration.
- Common emitter configuration is mainly used for amplification purpose because it exhibits the required voltage and power gain for amplification purpose.
- This configuration helps in increasing the input signal by 20dB which is nearly 100 times more than the input signal.
- Emitter current is the combination of base and collector current.
- Collector and emitter can be differentiated by their size and doping concentration. The emitter is highly doped while the collector is lightly doped.
- The forward current gain of the transistor can be denoted by beta ß which is a ratio between collector current and base current. This beta is actually an amplification factor which is a measure of current being amplified. Beta value ranges between 20 to 1000 but its standard value is 200. Beta is a ratio of two current so it has no unit.
- The current gain of this transistor is represented by alpha a which is a ratio between collector current and emitter current. Alpha value ranges between 0.95 to 0.99 and most of the times its value is considered as a unity.
Absolute Maximum Ratings of 2n4401
Absolute maximum ratings of 2n4401 is shown in the figure below.
- Collector-Emitter and Collector-Base voltages are 40 and 60 V respectively.
- If stresses are exceeded above these absolute maximum ratings, they can damage the device.
- Similarly, if stresses are applied for the extended period of time, they can affect the device reliability.
Difference between NPN and PNP transistors
- The main difference between NPN and PNP transistor is the availability of charge carriers. Electrons are majority charge carriers in case of NPN transistor while holes are majority charge carriers in case of PNP transistors.
- Most of the professional prefer NPN transistor over PNP transistor because conduction carried out by the mobility of electrons is better than conduction through mobility of holes.
- These NPN and PNP bipolar junction transistors are current controlled devices and are different than unipolar MOSFET that is a voltage controlled device.
Applications
- This transistor is mainly used for general purpose amplification.
- In many applications, this transistor behaves as a simple switch. When a voltage is applied at the base side, it gets biased and transistor behaves as an ON switch. When there is no voltage at the base side, it won't get biased and the transistor behaves as an OFF switch.
That's all for today. I hope you have enjoyed the article. I always try to give you information based on recent topics so you keep coming back for what we have to offer. If you feel skeptical or have any question, you can ask me in the comment section below. I'll try my best to help you in this regard according to best of my expertise. Stay tuned!
Introduction to 2n2905
Hey Everyone! I hope you all are doing great and enjoying life. I am back to give you daily dose of some valuable information so you can progress and grow in your relevant field. Today, I am going to unlock the details on the
Introduction to 2n2905. It is a PNP (Positive-negative-Positive) bipolar junction transistor (BJT) which is mainly used for general purpose and switching applications. In this transistor, N doped semiconductor exists between the two layers of P doped material. I am going to give you brief details about this transistor. Let's get started.
Introduction to 2n2905
-
- 2n2905 is a PNP bipolar junction transistor which is mainly designed for general purpose, small signal and switching applications.
- It comes in TO-39 casing and consists of three terminals called emitter, base and collector.
- N side represents the base of the transistors while other two P layers represent emitter and collector respectively.
- N represents the polarity at the base side which is negative and P represents the polarity at the emitter side which is positive.
- In order to flow current, base must be negative with respect to emitter.
- As it is a bipolar junction transistor so conduction is carried out by both charge carriers i.e. electrons and holes but majority charge carriers will be holes.
- Collectors-Base junction will always be reverse biased so opposite polarity must be required at the collector side.
- Base is negative with respect to emitter and collector will be more negative with respect to base.
- Small current at the base side is used to control large current at the emitter and collector side but majority charge carriers will be holes.
2n2905 Pinout
2n2905 is a PNP transistor which mainly consists of three terminals.
1: Base
2: Collector
3: Emitter
- This transistor is considered as a current controlled device where small current at the base side is used to control large current at the emitter and collector side.
- Emitter is highly doped while base will be lightly doped.
Circuit Diagram of 2n2905
Circuit diagram of this transistor is shown in the figure below.
- Current at the emitter side is equal to the sum of current at the base and collector side.
- Main difference between emitter and collector is their size and doping concentration. Emitter is highly doped while collector is lightly doped.
- Conduction is carried out by movement of both electrons and holes but majority charge carriers will be holes which will be collector by the collector.
Absolute Maximum Ratings of 2n2905
Absolute maximum rating of 2n2905 is shown in the figure below.
- Power dissipation is about 600mW.
- Collector-Base voltage and Collector-Emitter voltage is -60 and -40 respectively.
- These are the stress ratings. It is important to note that if stresses are exceeded above these absolute maximum ratings, they can damage the device at large.
- Also, if these stresses are applied for extended period of time, they can effect the device reliability.
Difference Between PNP and NPN Transistors
- Main difference between NPN and PNP transistors is the medium used for conduction. Electrons are majority charge carriers in case of NPN transistors while holes are majority charge carriers in case of NPN transistors.
- Most of the professional intend to prefer NPN over PNP transistors because they think that conduction carried out by mobility of electrons is better than conduction by the mobility of holes.
Combination of NPN and PNP Transistors
- Combination of NPN and PNP transistors can be used in most applications.
- If NPN are combined with PNP transistors, they can be used to design a power amplifier circuit with ideal output.
- Combination of these transistors can be used in Class B amplifiers where both transistors are used to control the current flowing in both directions at any instant of time.
- In Class B amplifiers both NPN and PNP transistors function in a similar fashion. PNP transistors conduct for the negative half cycle of the transistor while NPN conducts for the positive half cycle of the transistor.
- This helps in getting the power at output load in both directions.
- Transistors are termed as Complementary transistors which use the combination of both NPN and PNP transistors of identical characteristics.
Applications
- These transistors are used for high speed switching applications.
- Military and other high reliability driver applications involve these transistors.
That's all for today. I hope you have enjoyed the article. If you have any question, you can ask me in the comment section below. Your suggestion and feedback will be highly appreciated as it will allow us to provide you quality work that resonates with your needs and expectations. Stay Tuned!