Hello, everybody!
I'd like to make global type alias.
If I used c++ I would write the following code to create a global type
alias:
typedef SomeType MyAlias;
I've found that using keyword could be used to make type/namespace aliases.
using MyAlias = SomeTypeOrNames pace;
But such an alias applies only to current module and should be at the top of
it (not allowed inside class definition).
So is there any possibility to make a global type alias in C#?
Thanks in advance. 6 2604
Hi,
No other than that, why you use it s much? Personally I have never used it
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Maxim" <vmu [_at_] mail [ _dot_ ] ru> wrote in message
news:O$******** ******@TK2MSFTN GP05.phx.gbl... Hello, everybody!
I'd like to make global type alias.
If I used c++ I would write the following code to create a global type alias: typedef SomeType MyAlias;
I've found that using keyword could be used to make type/namespace aliases.
using MyAlias = SomeTypeOrNames pace;
But such an alias applies only to current module and should be at the top of it (not allowed inside class definition).
So is there any possibility to make a global type alias in C#?
Thanks in advance.
Thanks for answering, Ignacio No other than that, why you use it s much?
I don't. I'm new to C# and .NET and trying to figure out how it works.
I'm implementing WebService client now and proxy classes have very lengthy
names. And code looks confusing. So I decided to use some type aliases to
make it more readable.
"Maxim" <vmu [_at_] mail [ _dot_ ] ru> wrote in message
news:O$******** ******@TK2MSFTN GP05.phx.gbl... Hello, everybody!
I'd like to make global type alias.
If I used c++ I would write the following code to create a global type alias: typedef SomeType MyAlias;
I've found that using keyword could be used to make type/namespace aliases.
using MyAlias = SomeTypeOrNames pace;
But such an alias applies only to current module and should be at the top of it (not allowed inside class definition).
So is there any possibility to make a global type alias in C#?
No.
I like the above using syntax, though I usually won't do any renaming:
using ClassName = Namespace1.Name space2.ClassNam e;
This documents exactly what classes I'm using, and helps anyone who's
reading the code to find ClassName.
Oddly, the equivalent Java syntax
import p1.p2.ClassName ;
is standard, and
import p1.p2.*;
is considered lazy, where in C#, class-level using statements are almost
unheard of.
<"Maxim" <vmu [_at_] mail [ _dot_ ] ru>> wrote: No other than that, why you use it s much?
I don't. I'm new to C# and .NET and trying to figure out how it works. I'm implementing WebService client now and proxy classes have very lengthy names. And code looks confusing. So I decided to use some type aliases to make it more readable.
The thing is, it makes it *less* readable for other people - and to you
in a few months' time. Performing a mental translation from one type
name to another is harder work than just reading the longer name in the
first place, IMO.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote: The thing is, it makes it *less* readable for other people - and to you in a few months' time. Performing a mental translation from one type name to another is harder work than just reading the longer name in the first place, IMO.
I disagree. When I write
Dictionary<Main QueueIdentifier , StackPointer> queueReference = new
Dictionary<Main QueueIdentifier , StackPointer>() ;
the verbosity is so much that it gets in the way. The only way I have
to make it shorter is to use aliases (yuck, don't work outside the
current file, aren't used by intellisense) or to define my own class:
class QueueReference : Dictionary<Main QueueIdentifier , StackPointer>
{
... copy all of the constructors
}
This class hasn't helped at all. It's done exactly the same job as a
type-alias-directive would do, but at the cost of twenty extra lines
of code.
--
Lucian
Lucian Wischik wrote: Jon Skeet [C# MVP] <sk***@pobox.co m> wrote:The thing is, it makes it *less* readable for other people - and to you in a few months' time. Performing a mental translation from one type name to another is harder work than just reading the longer name in the first place, IMO.
I disagree. When I write
Dictionary<Main QueueIdentifier , StackPointer> queueReference = new Dictionary<Main QueueIdentifier , StackPointer>() ;
the verbosity is so much that it gets in the way.
I agree that it's somewhat ugly - although as I prefer to use
interfaces where possible, I'd have different types on the left hand
side and the right hand side anyway - but I personally prefer that to
having to look up the meaning of something elsewhere.
I guess it's a personal preference.
Jon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Ford |
last post by:
I have a macro that I use across the board for freeing ram. I'd like to
clean up my code so I don't get these warnings.
#define sfree(x) _internal_sfree((void **)&x)
#define _internal_sfree(x) ({ if(x && *x) { free(*x); *x=NULL; } })
void somefunction() {
char *x = malloc(10);
int *y = malloc(10);
|
by: Adam Warner |
last post by:
Hello all,
I'm very new to C but I have a number of years of Common Lisp programming
experience. I'm trying to figure out ways of translating higher order
concepts such as closures into C. The code will not be idiomatic C.
GCC has an extension to ISO C that permits nested functions:...
|
by: Scott Ribe |
last post by:
Here's my issue:
Data comes in and is inserted into the database automatically, into a base
table A. Later a human looks at the records, fills in some data, and now the
records are assigned to some derived table, B or C. In some cases there is
no way for the software to know at import time which derived type the data
actually is (that...
|
by: Xah Lee |
last post by:
in March, i posted a essay “What is Expressiveness in a Computer
Language”, archived at:
http://xahlee.org/perl-python/what_is_expresiveness.html
I was informed then that there is a academic paper written on this
subject.
On the Expressive Power of Programming Languages, by Matthias
Felleisen, 1990....
|
by: chaz |
last post by:
Hi,
* this class is defined in assembly XXXXClsLib :
Public class VVDB : inherits DBFuncs
...
* Assembly YYYYFwApi has a reference to XXXXClsLib
* this class B in YYYYFwApi has an imports stmt :
imports XXXXClsLib.VVDB
* and this code of class b gives an error
Private Function zzz() As String
| |
by: peter.tornqvist |
last post by:
Maybe I'm stupid or maybe I am missing the obvious, but I can't find a way
to define a type alias in C# for primitive types (class and interfaces I can
inherit from, no problem). I.e I want to declare a type that is an alias
for, say, int. Conceptually, this is what I want to do:
public MyIntType = int; // won't compile
Anyone knows how...
|
by: Alias |
last post by:
Hi -
I'm trying to implement a custom RoleProvider based on the SqlRoleProvider.
I keep receiving a an error that it can't load type
'MyRoleTest.MyRoleProvider' when trying to load my RoleProvider. However
this only occurs after deployment. On my local machine it works fine. So I
created the most basic role provider project I could think...
|
by: dillogimp |
last post by:
hi
This code is taken from a lisp interpreter by Andru Luvisi.
typedef struct obj {
enum otype type;
struct obj *p; // array of pointer, sizeof(obj)=8
} obj;
typedef obj * (*primop)(obj *);
obj *all_symbols, *top_env, *nil, *tee, *quote,
|
by: Slapo |
last post by:
Hello everyone,
I could use some help with this function I've created (see below) that runs flawlessly on PostgreSQL 8.3.6 on my development machine but ends with an error on the production server that has PostgreSQL 7.4.8 installed (see below).
My function:
CREATE OR REPLACE FUNCTION generate_menu(varchar(255), char(2), varchar(255), int,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |