Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Like Typedef(In C++) operation what is option in C#.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Swapnil - 21 Feb 2008 13:37 GMT
hi,

we can use Typedef in C++ . To perform the same operation in C# How can i
use?
Please Explain with example.
Jon Skeet [C# MVP] - 21 Feb 2008 13:45 GMT
>  we can use Typedef in C++ . To perform the same operation in C# How can i
> use?
> Please Explain with example.

There's no project-wide equivalent of typedef.

You can use using directives on a per file basis, e.g.

using FooBar = System.Console;

...

FooBar.WriteLine("Hi");

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Jeroen Mostert - 21 Feb 2008 20:29 GMT
>>  we can use Typedef in C++ . To perform the same operation in C# How can i
>> use?
[quoted text clipped - 5 lines]
>
> using FooBar = System.Console;

It's also common to simply derive a class when dealing with generic instances:

class MySpecialCollection : Dictionary<MyKeyType, MyValueType> {
    // add constructors as required
};

This is self-documenting and reduces the potential for typing errors.

Signature

J.

Misbah Arefin - 25 Feb 2008 15:39 GMT
//C++
typedef int NUMBERS;

//C#
using NUMBERS = System.Int32;

Signature

Misbah Arefin
https://mcp.support.microsoft.com/profile/MISBAH.AREFIN
http://www.linkedin.com/in/misbaharefin

> hi,
>
>  we can use Typedef in C++ . To perform the same operation in C# How can i
> use?
> Please Explain with example.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.