-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: chaitanyadbt
Message 2 in Discussion

Please send me some links related to ComponentArt1.1

Thanks and Regards

Chaitanya Vemulapalli







From: BDotNet@groups.msn.com
To: BDotNet@groups.msn.com
Subject: Dating Dotnet - The advantage of using “Using” in .Net
Date: Tue, 23 Oct 2007 02:33:14 -0700


<META content="Microsoft SafeHTML" name=Generator>
<STYLE>
ExternalClass EC_ThmFgColumnHeader, .ExternalClass EC_A.FrameLink, 
ExternalClass EC_A.HeaderLink, .ExternalClass EC_A.FooterLink, ExternalClass 
EC_A.LgtCmd, .ExternalClass EC_A.MSNLink
{color:#FFFFFF;}
ExternalClass EC_ThmFgTitleLightBk
{color:#FF6600;}
ExternalClass EC_ThmFgSmallLight
{color:#ff0000;}
ExternalClass EC_ThmFgNavLink, .ExternalClass EC_A.NavLink, ExternalClass 
EC_A.ChildLink:hover
{color:#666699;}
ExternalClass EC_ThmFgInactiveText, .ExternalClass EC_A.SystemLink
{color:#666666;}
ExternalClass EC_ThmFgFrameTitle
{color:#FFFFCC;}
ExternalClass EC_ThmFgTitleDarkBk, .ExternalClass EC_A.NavLink:hover, 
ExternalClass EC_A.TitleLink
{color:#CC6600;}
ExternalClass EC_ThmFgMiscText, .ExternalClass EC_A.Cat, .ExternalClass 
EC_A.SubCat
{color:#336699;}
ExternalClass EC_ThmFgCommand, .ExternalClass EC_A.Command, ExternalClass 
EC_A.LargeCommand, .ExternalClass EC_A.MsgLink
{color:#003366;}
ExternalClass EC_ThmFgHeader
{color:#333333;}
ExternalClass EC_ThmFgStandard, .ExternalClass EC_A.SystemLink:hover, 
ExternalClass EC_A.SubLink, .ExternalClass EC_A.ChildLink, ExternalClass 
EC_A.StdLink, .ExternalClass EC_SELECT.Standard
{color:#000000;}
ExternalClass EC_ThmFgDivider
{color:#CCCCCC;}
ExternalClass EC_ThmBgStandard
{background-color:#FFFFFF;}
ExternalClass EC_ThmBgUnknown1
{background-color:#FF6600;}
ExternalClass EC_ThmBgFraming
{background-color:#666699;}
ExternalClass EC_ThmBgUnknown2
{background-color:#666666;}
ExternalClass EC_ThmBgHighlightDark
{background-color:#FFFFCC;}
ExternalClass EC_ThmBgHighlightLight, .ExternalClass #EC_idToolbar, 
ExternalClass #EC_tbContents
{background-color:#FFFFE8;}
ExternalClass EC_ThmBgTitleDarkBk
{background-color:#F1F1F1;}
ExternalClass EC_ThmBgAlternate
{background-color:#ECF1F6;}
ExternalClass EC_ThmBgUnknown3
{background-color:#CCCCFF;}
ExternalClass EC_ThmBgDivider
{background-color:#CCCCCC;}
ExternalClass EC_ThmBgHeader
{background-color:#9999CC;}
ExternalClass EC_ThmBgLinks
{background-color:#8696C9;}
ExternalClass EC_ThmBgSharkBar
{background-color:#8696C9;}
ExternalClass EC_ThmBgGlobalNick
{background-color:#9394A9;}
ExternalClass EC_calfgndcolor
{color:#E00505;}
ExternalClass EC_calbgndcolor
{color:#E00505;}
</STYLE>





New Message on BDOTNET



Dating Dotnet - The advantage of using “Using” in .Net





Reply





 
Recommend 
Message 1 in Discussion 





From: VBGURU 



 source: 
http://www.aravinda.in/Tech.aspx?Title=The_Advantage_of_Using_Using&WebPage=tech\dotnet\TheAdvantageofUsingUsing.htm
 

@ www.aravinda.in


Usage 1
using Directive

The using directive has two uses: 


        Create an alias for a namespace (a using alias). 
        Permit the use of types in a namespace, such that, you do not have to 
qualify the use of a type in that namespace (a using directive). 
Create a using alias to make it easier to qualify an identifier to a namespace 
or class.

Create a using directive to use the types in a namespace without having to 
specify the namespace. A using directive does not give you access to any 
namespaces that may be nested in the namespace you specify.

Namespaces come in two categories: user-defined and system-defined. 
User-defined namespaces are namespaces defined in your code. See the 
documentation for the .NET Framework for a list of the system-defined namespaces

 

The following sample shows how to define a using directive and a using alias 
for a class:

// cs_using_directive2.cs

using System;   // using directive

using AliasToMyClass = NameSpace1.MyClass;   // using alias for a class

 

namespace NameSpace1 

{

   public class MyClass 

   {

      public override string ToString() 

      {

         return "You are in NameSpace1.MyClass";

      }

   }

}

 

namespace NameSpace2 

{

   class MyClass 

   {

   }

}

 

namespace NameSpace3 

{

   using NameSpace1;   // using directive

   using NameSpace2;   // using directive

 

   class Test 

   {

      public static void Main() 

      {

         AliasToMyClass somevar = new AliasToMyClass();

         Console.WriteLine(somevar);

      }

   }

}

Output

You are in NameSpace1.MyClass

Usage 2
 

The other most important usage of using Using is

 

using Statement (C# Reference)

Defines a scope, outside of which an object or objects will be disposed.

Syntax

 

        using (Font font1 = new Font("Arial", 10.0f))

{

}

 

C#, through the .NET Framework common language runtime (CLR), automatically 
releases the memory used to store objects that are no longer required. The 
release of memory is non-deterministic; memory is released whenever the CLR 
decides to perform garbage collection. However, it is usually best to release 
limited resources such as file handles and network connections as quickly as 
possible. 

The using statement allows the programmer to specify when objects that use 
resources should release them. The object provided to the using statement must 
implement the IDisposable interface. This interface provides the Dispose 
method, which should release the object's resources.

A using statement can be exited either when the end of the using statement is 
reached or if an exception is thrown and control leaves the statement block 
before the end of the statement.

The object can be declared in the using statement, as shown above, or before 
the using statement, like this:

 

The following sample shows how a user-defined class can implement its own 
Dispose behavior. Note that your type must inherit from IDisposable.

using System;

 

class C : IDisposable

{

    public void UseLimitedResource()

    {

        Console.WriteLine("Using limited resource...");

    }

 

    void IDisposable.Dispose()

    {

        Console.WriteLine("Disposing limited resource.");

    }

}

 

class Program

{

    static void Main()

    {

        using (C c = new C())

        {

            c.UseLimitedResource();

        }

        Console.WriteLine("Now outside using statement.");

        Console.ReadLine();

    }

}

source: 
http://www.aravinda.in/Tech.aspx?Title=The_Advantage_of_Using_Using&WebPage=tech\dotnet\TheAdvantageofUsingUsing.htm

@ www.aravinda.in


View other groups in this category. 









To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings. 

Need help? If you've forgotten your password, please go to Passport Member 
Services. 
For other questions or feedback, go to our Contact Us page. 

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list. 
Remove my e-mail address from BDOTNET. 
Check out some new online services at Windows Live Ideas—so new they haven’t 
even been officially released yet. Try it!

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to