|
Thanks guys for your input!
I am still curious though if there was a way to get access to the TextBox directly. Any thoughts there?
|
|
|
|
|
I am working on a wrapper for the XML stuff in C#, and I want to add the ability to easily declare common namespaces. What I'd like to be able to do is have an enum called Namespaces, and do this
MyDoc.Namespace |= Namespaces.XSL & Namespaces.dt;
The question is, if I define a property and make it an int, will my set method get called, will this expand to
MyDoc.Namespace = MyDoc.Namespace |( Namespaces.XSL & Namespaces.dt);
or would I be better to define operator | and operator & for my enum ?
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Christian Graus wrote:
The question is, if I define a property and make it an int, will my set method get called, will this expand to
MyDoc.Namespace = MyDoc.Namespace |( Namespaces.XSL & Namespaces.dt);
To quote my favorite professor. *clears throat* "Try it and find out"
I would bet that it would work as you expect, but you should put the FlagsAttribute on your enum and then use an enum of the same type for the property.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
James T. Johnson wrote:
Try it and find out
Yes, you're right. The reason I often ask such dumb questions is I think about stuff on the bus and don't have .NET at work....
James T. Johnson wrote:
I would bet that it would work as you expect, but you should put the FlagsAttribute on your enum and then use an enum of the same type for the property.
Flags allows the enum to be a combination of the values ? Does it also automatically set the values to 1, 2, 4, 8, 16... ?
Thanks
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Christian Graus wrote:
The reason I often ask such dumb questions is I think about stuff on the bus and don't have .NET at work....
I'm not faulting you for it; it was just my way of saying I don't know without actually saying it
Christian Graus wrote:
Does it also automatically set the values to 1, 2, 4, 8, 16... ?
I don't think so, and a quick test confirms that it doesn't. It would have been a nice feature; but I think in the face of consistancy it is a good thing that it doesn't.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
James T. Johnson wrote:
I don't think so, and a quick test confirms that it doesn't.
Oh. So I need to do that manually ? Does the flag just allow an instance of the enum to be any value then, not just the ones defined ?
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Christian Graus wrote:
Oh. So I need to do that manually ?
Yep
Christian Graus wrote:
Does the flag just allow an instance of the enum to be any value then, not just the ones defined ?
It allows any value, just like any other enum.
If you look at the IL for an enum, it is essentially a special type of class. Here is some code that is somewhat equivalent.
[Flags]
public enum TestE
{
ItemA = 1,
ItemB = 2,
ItemC = 4
}
public sealed class TestE : System.Enum
{
public const int ItemA = 1;
public const int ItemB = 2;
public const int ItemC = 4;
public int value__;
} A little bit of 'magic' is employed when assigning and retreiving the values in that referring to the value__ field isn't necessary. Essentially an enum is a strongly named collection of (compile-time) constant values.
Obviously a bit more magic is employed so that values can be cast willy-nilly to an enum type and add support for the Enum.Parse method.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
James T. Johnson wrote:
It allows any value, just like any other enum.
So as far as values are concerned, an enum is still essentially an int ?
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
an int, byte, short, long, ... whatever you declare it to be; by default it is an int.
public enum FooBarBaz : <datatype>
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
add the Flags attribute to your enum, and your property can be the enum type.
|
|
|
|
|
I've recently been pointed in the direction of RegExps for string replacement.
However, being new to both C# and RegExps, and Escape characters are giving me fits!
I've got got to remove the following characters from a string (not including the double quotes)
"`!@$%^*()+=\|[]{};:<>/?,~"
I'm having an awful time trying to evaluate what needs to be "escaped", and how many times!
ugh.
Mike Stanbrook
mstanbrook@yahoo.com
|
|
|
|
|
"^[a-z0-9_]"
the above expression should [i think] remove all characters that are not letters, numbers or the underscore, to not remove any other chars, just add them in next to the underscore.
p.s. if you dont want to keep underscores, then remove it.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
|
except the " char, which needs to be escaped with a double quote ala vb
|
|
|
|
|
Here's what I've tried:
sourceString = "123 ABC X!Y%Z}"
System.Text.RegularExpressions.Regex.Match(sourceString,"^[a-z0-9_]").ToString()
which results in: "1" (why only one character?)
I've also tried the suggestion:
System.Text.RegularExpressions.Regex.Match(sourceString,@"`!@$%^*()+=\\|[]{};:<>/?,~").ToString()
Which results in:
error: managed EE does not understand expression's syntax
Removing the @ gives a result of "" (Empty string).
Mike Stanbrook
mstanbrook@yahoo.com
|
|
|
|
|
im sorry, the ^ was meant to be inside the brackets, do this
string sourceString = "123 ABC X!Y%Z}";
Regex r = new Regex(@"[^a-z0-9]", RegexOptions.IgnoreCase);
MessageBox.Show(r.Replace(sourceString, ""));
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
|
|
Hi
First for Regex, Eric Gunnerson has a nice tool (although i have no clue how Regex works ). Look on the GotDotNet.com website under user samples.
Secondly, lets solve this problem
string badchars = @"`!@$%^*()+=\|[]{};:<>/?,~";
foreach (char bad in badchars) input = input.Replace(bad.ToString(), null );
Thats it, Hope it helps
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
|
HAHA!
That was my original approach!! It was suggested that a "better way" was using RegExps.
(My example at that time was stripping "{","-", and "}" from GUIDs.
Funny how some things come full circle!
(note: I wasn't able to find Eric's tool, but there was a RegEx Workbench that might do the trick).
Thanks.
Mike Stanbrook
mstanbrook@yahoo.com
|
|
|
|
|
MStanbrook wrote:
(note: I wasn't able to find Eric's tool, but there was a RegEx Workbench that might do the trick).
I'm a spazz. The RegEx Workbench *IS* Eric's tool.
Mike Stanbrook
mstanbrook@yahoo.com
|
|
|
|
|
Sorry , i was gonna reply but it slipped my mind, glad you made the association
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Usually, DateTimePicker control shows the date (short date), but when you pass the value of it into a datetime type variable, it has the time too. And I found the time may varies, ( I got 8/15/2002 12:00:00 am once, and 8/15/2002 12:31:21 pm the other time). Both of them are not my computer time. Can someone tell me what is going on with the time value?
|
|
|
|
|
How do I make the output of my program screen size independent? I'm writing code that prints out bitmaps, a status bar, and other stuff. It looks great on my 19" screen, but when I use anything smaller, the output is cut off. Thx,
Ralf.
ralf.riedel@usm.edu
|
|
|
|