The Using statement Visual Studio

Hello friends, my name is Rahul Bharadwaj, and I am a professional blogger, I have created this blog only for you so that you can get good information from this blog, and that too for free.  I keep posting articles about web development, programming language, and script language on this blog every day for you people.  So that you can get some information by reading this article.  So that you people can also learn web development, application development, programming language, and script language by yourself by reading the posts on my blog.  You people also want you earn money online by learning web development, application development, programming language, and script language. Today I am going to write a very good post for you on this blog so that you can learn web development,  It will be easy to learn application development, programming language, and script language.  Today I am going to tell you about The Using statement Visual Studio of in this post.  And I request you that you will like this post of ours.


The Using statement Visual Studio


The Using statement is used to
import a namespace, so you do not have to qualify items in that namespace by
listing the entire namespace when you refer to them. For example, to use
classes and methods for file handling, which is present in the system. IO
namespace, you just need to include the namespace System. IO. If you do not
include the namespace, the classes and methods referring to them are not
displayed in the code file. The StreamWriter class is only displayed when the
System.IO namespace is included using the statement as follows. The Write
method of the StreamWriter class.


The writes the text in the text
file, as shown in the following the code snippet:


using System.IO;

protected void Button1
Click(object sender, EventArgs e)


Streamwriter sw = new
Streamwriter(“C:/abc.txt”); sw.write(“hello!
w.write(“hello! i am new file”);


Declaring Constants


The Constants are the names given
to values that do not change the during the an execution of a program.
Constants are useful when we have to use a value at many places in a program
without changing its values. If we declare a value as a constant at one point
and for further references to that value, we use the name of the constant
instead of the value, then the all an instances of that value can be the
modified by the changing only the value of the constant at the declaration.


In Visual C# 2012, constants are
declared with the keyword const, as shown here:


const [
<attrlist> ] [  accessmodifier] constant list


Some of the keywords of the
preceding statement have already been defined in Table. The definitions for the
remaining are as follows: 


(i). Constant list: Displays list of constants declared in
the statement. Each constant in the constant.


must use the following syntax and parts: 




(ii). Name: Declares the name of the constant. You
can declare as many constants as you like in the same declaration statement,
specifying the name and initexpr parts for each. Multiple constants are
separated by commas.



Read More…Login Controls in ASP. NET Visual Studio


(iii). Type: Represents the data type of the constant.
It can be Booleans, Bytes, Chars, Date, Decimal, Double, Integer, Long,
Objects, SByte, Short, Single, String, UInteger, ULong, or UShort. It can also
be the name of an enumeration.


(iv). Initexpr: Represents an initialization expression.


Multiple constants can be
separated with the help of commas as shown here:


constant [, constant…


Here, it is shown how to declare
and use a constant. In this case, we create a constant named Pi and variables
named as Area and Radius. We then use the *(multiplication) operator to find
the area of a circle and display the result:


protected void
Button1Click(object sender, EventArgs e)

const double Pi = 3.14;

double Radius, Area;

Radius = 2;

Area Pi (Radius Radius);
Response.write(“Area = “+Ar +Area);


Declaring Variables


A variable is a storage element
in C#. This implies that a variable can store one or more values of a type,
such as an int, float, char, and string. As the name indicates, the value of a
variable can be ged, but the name remains the same. A variable is a form of
field and can be assigned a value at the time of its declaration by using the
operator. The following are some examples of variable durations and assignments:



Read More…The Linq DataSource Control Using C#


int i;




In the first line of the
preceding code, we declare a variable named “i” of the integer data
type. The end line of the code assigns a value of “15” to the integer
variable “i”. A variable can be local or class. Local variables
exist within the scope of a given method in a class, whereas class variables
exist the entire lifetime of the object instance of a class. Class variables can
be used in any method and can be public, private, or protected, just
similar to the methods. If a class variable is public, it is read or written
from any class method, whether or not that method resides within the same
class. variables cannot be defined as public or private because they are not
accessible outside the hod in which they are defined.


C# also uses static class
variables, which can be used in static class methods. A single instance of the
c class variable exists for all instances of a given class. Variables can be
used of either simple or y types. 


Int[] arr=new


Variables, however, are not
restricted to simple Value types or arrays of those Value types. You can also
define the variables that are user-defined types. For example, you can the
create an enumeration, as we have the discussed earlier in this chapter.
Alternatively, you can the create a class instance(object) by writing the


Demo d=new Demo();


The default data type, if you do
not specify one, is Object. If a variable is not initialized to a value, it is
initialized to a default value for its data type. The following are the default
values for the respective data types:


1. O for all numeric types
(including Byte).


2. Binary O for Char.


3. NULL for all reference types,
such as Object, String, and all arrays. It indicates that no object is
associated with the reference.


4. False for Boolean.


5. 12:00 AM of January 1 of the
year 1 for date (01/01/0001 12:00:00 AM).



Read More….WebParts Controls in ASP. NET Using Visual Studio


A new object is created using the
new keyword. For example, a new Text Box control in Visual C# is created
through the Code window as follows:


“TextBox TextBox1= new


It is not necessary to create a
new object by using the new keyword at the time of its declaration. We can also
create it at some other place later in the program by using the new keyword, as
shown here:


“Textbox TextBox1;

TextBox1 = new


In Visual C#, the new object is
created immediately if you declare it with the new keyword. You can declare
multiple variables of the same data type without repeating the type keyword:


“int count,


In the preceding code snippet, we
have declared the two variables count1 and count2 of the int data type without repeating
the Integer keyword twice.The Variable names can be prefixed to indicate their
the data type. However, the use of these prefixes is optional.


Table lists some of the prefixes
for the Visual Basic data types:


Data Type


Boolean Bln
Byte Byt
Collection object Col
Date (Time) Dtm
Double Dbl
Error Err
Integer Int
Long Lng
Object Obj
Single Sng
String Str
User-defined type Udt


The use of variable prefixes that
are defined in the preceding table provides some information regarding the
variable’s data type. It can be extremely helpful when someone else reads your
code. In the next section, we learn about data types available in Visual C#


Introducing Data Types


A data type determines the type
of data that is stored in a variable. It can be a String, Integer, or
Boolean. For creating a new the variable, we should first know the range of
possible values a  particular the variable type allows. The table lists the
data types of Visual C#:


 Visual C# 2012 Data Types




Boolean Depends on implementation
Byte 1 byte
Char (single character) 2 byte
Date 8 byte
Decimal 16 byte


Converting Data Types


When you have to convert a variable
of one data type to another, we should first know if the conversion is possible
or not. The Conversion between two the data types is possible only when they
are the compatible. Visual C# 2012 provides some conversion functions, which
are useful for conversion between incompatible data types, as shown in the
following Table.


Conversion Method


To Boolean Converts a value to a Boolean
value, if possible
To Byte Converts a value to a byte
To Char Converts a value to a single
character(Unicode), if possible
To Date Time Converts a value to date-time
To Decimal Converts a value to decimal
To Double Converts any value to a double-type
To Int 16 Converts any value to an int
To Int32 Converts any value to a long
To Int64 Converts any value to a long
To Sbyte Converts a given value to a
single byte field
To Single Converts any value to a small
floating-point number
To String Converts virtually any value to a string
To Ulnt16 Converts to an unsigned int
data type
To Ulnt32 Converts to an unsigned long
data type
To Ulnt64 Converts to an unsigned big


 The Arithmetic Operators


Almost all computer programs
perform arithmetic operations, such as subtraction, multiplication, and
division. You must have knowledge of all the operators used in Visual C#.
The list of six arithmetic operators present in Visual C# is given in Tables.


The table shows the use of the
plus (+) operator for addition and the minus (-) operator for subtraction:


Arithmetic Operators-Addition
and Subtraction





Addition 18+2 20
Subtraction 12-2 10


Table  shows the use of the asterisk (*) for
multiplication and (/) for division:


Table -Arithmetic
Operators-Multiplication and Division:





Multiplication 4*4 16
Division 50/25 2


The other two arithmetic operators
are integer division (1) and Modulus (%). For dividing integers, the backslash
character () is used. If you get any remainder from the division, it is
ignored. The modulus operator, represented by the symbol, is just the opposite.
It divides two numbers and returns only the remainder. The table shows these


Now, consider an example where an
arithmetic statement contains more than one arithmetic operator:




What can be the answer? The
answer depends on how you proceed. If you go from left to right and add 5 and 3
first and then multiply by 2, the answer is 16. However, if you multiply 3 by 2
first and then add 5 to it, the answer will be 11. Confused? This might seem
quite confusing to you, but the possibility of such confusion can be avoided by
having rules of precedence. That means arithmetic operations are performed in a
specific order of precedence. The order is as follows:


“Exponentiation (A)

Multiplication (*) and division
(/) division ()

Modulus (%)

Addition (+) and subtraction


Therefore, in an assignment
statement, exponentiation operations are done first, then multiplication and
division, integer divisions, modulus operations, and finally, additions and
subtractions. Therefore, the answer in our example will be 11 instead of 16
since multiplication is done before addition. 


In case the precedence level
of two operators are the operations are done from left to right. For example:
the same, for example, multiplication and division, the operations are done
from left to right. For example:




In the preceding example, since
both the operators have the same precedence level, the division will be done first
(due to the standard order of operations), yielding the result 10. A multiplication operation will then be performed, which will result in 50. In
case we want to perform multiplication first and then This division, we have to
use the parenthesis operator to force operations within the parenthesis to be performed first. If we rewrite the example, it will be as follows: 


20/ (2×5)


Here, the multiplication is done
first and then the division operation is performed, yielding the final result
as 2. There is no limitation on the number of parentheses to be used; however,
remember that every opening parenthesis needs a closing parenthesis. If you
type an assignment statement in the AP Visual C# Code window with unmatched
parenthesis (a syntax error), the end of the statement is Le
“squiggle,” indicating an error. When you nest a set of parentheses
within another set of parentheses, the evaluation starts with the innermost set
of parentheses and moves outward. For example:


((2+3) 5) +7


In this case, the addition of 2 and 3
is performed first and then the result is multiplied by 5, and finally, 7 is
added to the result. Therefore, the final answer comes to be 32. 


String Concatenation


This process of adding two
strings is called string concatenation. The addition (+) operator is used
for concatenation. Let’s look at the following example:


Concatenated_String =
“Visual ” + “C# 2012”


The variable Concatenated String
now contains the value “Visual C# 2012.” You can also use the (+)
operator to concatenate two strings. As usage of String variables. a developer,
it will be better if you become comfortable with the usage of String.




So, friends, I hope you liked this article and you must have understood and learned The Using Statement Visual Studio. To create computer and laptop applications and software, you need to know ASP.Net and its coding.  So that you can create software for computers, PCs, and laptops.



Finally, I would like to tell you that if you liked this information about The Using Statement Visual Studio, and you liked our post, then do share it on social media so that other people can also learn it.  If you want to ask anything, please comment below.


 The Using statement Visual

Leave a Comment