If the goal is simply to get the text of your choosing to appear in
IntelliSense, wouldn't it make more sense to use the XML documentation
to do this?  E.g.

public enum DateTimeFormats
{
  /// <summary>MM/dd/yyyy HH:mm:ss</summary>
  MonthDayYearTime,

  ... etc.
}

Visual Studio .NET will display the text in the <summary> element in a
tooltip when you highlight the item from the IntelliSense popup.


I think that the problem with what you're trying is that embedding
Unicode escape sequences is no different from embedding the underlying
character itself.  So this:

  MM\u02fdd\u02fyyyy

is treated by the compiler as being exactly equivalent to this:

  MM/dd/yyyy

and according to section 2.4.2 of the C# Language Specification, that's
not a valid identifier.  Identifiers can contain letters, decimals,
connecting characters, combining characters, or formatting characters.
I'm not that familiar with Unicode character classes, but I don't think
that "/" belongs to any of those.  I don't think "\" does either, so
attempting to escape the "\" won't help you.  (I think the space and the
":" are also problematic.)

You could probably write such an enum in IL (unless it's forbidden by
the ECMA specs - not sure off hand).  But you wouldn't be able to
consume it in C#, so there's not much point in trying.


-- 
Ian Griffiths
DevelopMentor


> -----Original Message-----
> From: Bill Bassler [mailto:[EMAIL PROTECTED]
> 
> I would like to create an enumeration that exposes a set of values
that
> allow a client to select from a list a formatting options.
> 
> For example:
> 
> DateRange scheduleEventsDateRange = new DateRange(args[0], args[1],
> DateTimeFormats.MM/dd/yyyy HH:mm:ss <== client to select value from
enum.
> 
> I thought that it might be possible to use Unicode encoding to specify
the
> characters that I would like displayed by Intellisense when the
component
> is coded against. However, there are a couple of problematic
characters
> when trying to generate an identifier in the form  - MM/dd/yyyy
HH:mm:ss
> The backslash and I assume the whitespace.
> 
> There appears to be an issue with the using a backslashes' Unicode
> representation as \u047.
> 
> For example:
> 
> public enum DateTimeFormats
> {
>     \MM\u047dd\u047yyyy    // and so on
> }
> 
> Question1: Is there a way to make this work using an enum?
> Question2: Is there a better way to acheive the same result with
another
> object or structure?
> 
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
> NEW! ASP.NET courses you may be interested in:
> 
> 2 Days of ASP.NET, 29 Sept 2003, in Redmond
> http://www.develop.com/courses/2daspdotnet
> 
> Guerrilla ASP.NET, 13 Oct 2003, in Boston
> http://www.develop.com/courses/gaspdotnet
> 
> View archives and manage your subscription(s) at
> http://discuss.develop.com

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com
NEW! ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to