Still a newbie to C#. How do I declare a Guid as a constant?
public const Guid GUID_BLUETOOTH_HCI_EVENT = new Guid(0x850302a, 0xb344,
0x4fda, 0x9b, 0xe9, 0x90, 0x57, 0x6b, 0x8d, 0x46, 0xf0);
gives me the following error: "The expression being assigned to
"...GUID_BLUETOOTH_HCI_EVENT" must be constant"
String and array initializers give me trouble also.
So how/can I declare a Guid as a constant in C#?
Thanks,
Brent 2 6643
You should declare it as a static readonly , since it is an object.
Only value types can be declared as conts. Declare it like this:
public static readonly GUID MY_GUI = Guid.NewGuid();
---
Regards,
Roy Osherove www.iserializable.com
On Thu, 6 Nov 2003 09:38:41 -0500, "Brent Horine"
<bh*****@NOSPAMMINGPLEASEclarcona.com> wrote: Still a newbie to C#. How do I declare a Guid as a constant? public const Guid GUID_BLUETOOTH_HCI_EVENT = new Guid(0x850302a, 0xb344, 0x4fda, 0x9b, 0xe9, 0x90, 0x57, 0x6b, 0x8d, 0x46, 0xf0);
gives me the following error: "The expression being assigned to "...GUID_BLUETOOTH_HCI_EVENT" must be constant"
String and array initializers give me trouble also. So how/can I declare a Guid as a constant in C#?
Thanks,
Brent
Thanks Roy.
"Roy Osherove" <ro**@iserializable.com> wrote in message
news:oo********************************@4ax.com... You should declare it as a static readonly , since it is an object. Only value types can be declared as conts. Declare it like this:
public static readonly GUID MY_GUI = Guid.NewGuid(); --- Regards,
Roy Osherove www.iserializable.com
On Thu, 6 Nov 2003 09:38:41 -0500, "Brent Horine" <bh*****@NOSPAMMINGPLEASEclarcona.com> wrote:
Still a newbie to C#. How do I declare a Guid as a constant? public const Guid GUID_BLUETOOTH_HCI_EVENT = new Guid(0x850302a, 0xb344, 0x4fda, 0x9b, 0xe9, 0x90, 0x57, 0x6b, 0x8d, 0x46, 0xf0);
gives me the following error: "The expression being assigned to "...GUID_BLUETOOTH_HCI_EVENT" must be constant"
String and array initializers give me trouble also. So how/can I declare a Guid as a constant in C#?
Thanks,
Brent This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: tom |
last post by:
Hi,
How do I get the serial number of the harddisk in .NET?
I want this to be the same number even if the user has
reformatted, so I do not want the volume serial number.
Thanx,
t
|
by: PawelF |
last post by:
I need to replace string with Guid ready to use:
public const string GUID_1 = "CF0003D61F6E4D6AA6B17B18E5057FCD";
like
public const Guid ...
Is there any chance to do this.
|
by: ESPNSTI |
last post by:
Hi,
I'd like to create a Guid constant and the following doesn't work (Cannot
implicitly convert type 'string' to 'System.Guid') :
public const Guid MyGuid =...
|
by: Dan Sikorsky |
last post by:
The event SomeEvent() is raised and handled in VB6 fine. Using this exact
same code and using VBScript with the CreateObject call causes an error in
the c# code.
When using VBScript, I get a...
|
by: Lee Crabtree |
last post by:
I've been wrapping an unmanaged class, and everything has gone well. That
is...until now.
I've hit a wall while trying to marshal the System::Guid type down into the
unmanaged GUID structure...
|
by: Roy |
last post by:
Hi,
I have a problem that I have been working with for a while.
I need to be able from server side (asp.net) to detect that the file i'm
streaming down to the client is saved...
|
by: Crirus |
last post by:
Is there a function that return some random ID like string alphanumeric?
Like this:
A35sDsd1dSGsH
Thanks
Crirus
|
by: Pyrus |
last post by:
Hi,
I'm new to the XPath thing and I found lots of expressions which usually only work correctly with XMLSpy (for some reason).
I would like to copy a complete xml through an xpath (yes...
|
by: Adem |
last post by:
HOWTO: const and pointer variants in C and C++ :
void test()
{
int n = 1; // n is non-const data of type int
++n; // ok
const int c = 2; //...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
|
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 project—planning, coding, testing,...
| |