Interviews8 answers
what is the significance of "using" keyword in c#?
8 Answers
Using Imports the All the Details of within the Namespaces
you can write you were own classes and use it multiple places in your application
For Example
using system.Data ;
means
It will Imports the Dataset, DataTable classes with respective Methods,Events and etc Properties
Suresh MogudalaPosted Sep 11, 2014, 10:49 PM EDT
Take one Class Library and Build it
namespace Example
{
public class sample
{
public int math(int i,int j)
{
return (i + j);
}
}
}
Now you want to Use math(or any thing from the Example NameSpace) method in your forms/Application
You should Add the Reference(from Bin folder of Example classlibrary) and Mention Namespace Name so that It can be Included li
//Importing the Example Namespace Classes or any thing from the Namespace
using Example;//Region of code can be access
Public class mathOperations
{
static void Main(string[] args)
{
//Creating Object for Sample Class
sample sa = new sample();
//object with Parametarized Methods calling
Console.WriteLine("Adding Two Numbers: " + sa.math(10, 20));
Console.ReadLine();
}
}
Suresh MogudalaPosted Sep 11, 2014, 10:49 PM EDT
using is the system keyword which is used for importing the namespace..
for example
using system.
here system is the namespace.for importing any namespace you must need to use the "Using" Keyword
Abhijit PatilPosted Jun 21, 2014, 3:18 AM EDT
using keyword is used to define the scope of object being created. Once code is get executed outside the using block the resource get released from memory
Pradeep ShetPosted Jun 15, 2014, 1:12 PM EDT
Using keyword will be used when we want to release unmanged resources that have associated with object and occupy unnecessary memory . It will be used like -
using(SqlConnection sqlconnection= new SqlConnection(connectionString) )
{
}and class Object
Ravi PrakashPosted Jun 5, 2014, 5:18 AM EDT
Using keyword will be used when we want to release unmanged resources associated with object. It will be used like -
using(SqlConnection sqlconnection= new SqlConnection(connectionString) )
{
}
Here connection object will release connection with database after using block.
Actualy compiler convert Using block into try/finally block where unmanged resouce will be released in finally block. Even if exception occured in using block, unmanged resource will be released in finally block.
It is actualy callling dispose method of object after completion of using block. We can create multiple objects in using block.
Swaraj PatilPosted May 27, 2014, 7:30 AM EDT
http://msdn.microsoft.com/en/library/yh598w02.aspx
http://www.codeproject.com/Articles/6564/Understanding-the-using-statement-in-C
Bhabani PrasadPosted May 26, 2014, 10:02 AM EDT
http://en.wikibooks.org/wiki/C_Sharp_Programming/Keywords/using
http://www.codeproject.com/Articles/6564/Understanding-the-using-statement-in-C
Khan Abrar AhmedPosted May 26, 2014, 2:51 AM EDT






