|
Well... I'd have to say you do not provide us enough information. If your bools are related and used internally, yeah, I would group them into a [Flags] type enum. I wouldn't expose an enum from object though. That just doesn't seem like good practice to me. I would have 10 public properties that wrap a [Flags] type enum though. Thats about the same thing as packing them with the binary operators. If you are calling native C++ code, you have to use the binary operators, so there is no choice there, but I'd still have the class expose 10 public properties and wrap all that internally. If its all managed code, well... again it depends on your situation. If you have 10 bools vs. a [Flags] type enum, then the enum is going to be more efficient in transfering on the WIRE... who cares about memory usage... not important at this level. Maybe if you are working on a CE device with limited resources, it may be, but on a PC? you are wasting your time thinking about things like this.
|
|
|
|
|
SledgeHammer01 wrote: I wouldn't expose an enum from object though ... I would have 10 public properties
I have either one public property or use a parameter (for a method or the constructor as appropriate) to pass in an Options enumerated value, as with passing options to a Regex.
|
|
|
|
|
Bad idea (sometimes). Property grids (i.e. in designers) don't play nicely with flag enums. Also, flag enums don't play nicely with data binding if you are using WPF or even Winforms.
|
|
|
|
|
SledgeHammer01 wrote: flag enums don't play nicely with ... Winforms.
I haven't had that problem.
|
|
|
|
|
As stated above, use an enum for your bool s. Something like:
[Flags]
public enum MyBools : int
{
MyBool1 = 1,
MyBool2 = 2,
MyBool3 = 4,
MyBool4 = 8,
...
MyBool10 = 512,
}
public bool HasBool(int sumOfBools, MyBools specificBool)
{
return ((sumOfBools & specificBool) > 0);
}
|
|
|
|
|
Bernhard Hiller wrote: return ((sumOfBools & specificBool) > 0);
As a general test I prefer to test against the provided value (specificBool) rather than 0, because the specificBool may have multiple bits set.
Plus, in .net 4 (if you use that), there is the built-in Enum.HasFlag Method.
modified 25-Nov-11 10:26am.
|
|
|
|
|
If you want this to cover a flag uint from interop or something else where you don't want an enum, you can do something like
public struct Flags {
public uint Value;
public bool this[int i] {
get { return 1 & (Value >> i); }
set { uint mask = 1 << i; Value = (Value & ~mask) | (value ? 1 : 0) << i; }
}
}
... to provide indexed access to a set of flags.
|
|
|
|
|
But I think that can only test one bit at a time.
|
|
|
|
|
I have a desktop application developed in c# .net for winows 7 opearating system.Will I be able to install the same application on my tablet pc and use it.It has user actiona like button click how will this events be handled in tablet pc? Can some one help me in this front.
|
|
|
|
|
What happens when you try it?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
A button click is still a button click whether or not a finger or a mouse pressed it.
|
|
|
|
|
hello please help me to make md4 Hashe in c#.
i Find some codes but not work Correctly.
i want C# code for Make Md4 Hash and me love Summary code
|
|
|
|
|
You do realise that MD4 was smashed like 20 years ago? If this is a new application, I would suggest you use SHA1, or at least MD5. If you really need to implement MD4 to support an older app, MD4 - Koders.com[^] is an implementation that is open source.
Hope this helps.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
yes i want MD4 realy.
but can not run this code
i want real project that can run in computer
|
|
|
|
|
Well, you're not going to get one because, as it's already been said, MD4 has been useless for the last 15-20 years because of its weaknesses. You'd probably be the 20th person on this earth still using it.
|
|
|
|
|
i understand md4 is bad is very bad but i nescery md4
|
|
|
|
|
Presumably someone told you to do it that way for business need.
If so I would research the relevant problems with that and then present that to that person and insist that they sign off on that document themselves and then you keep a record of it. That way when (not if) a problem occurs you are in the clear.
|
|
|
|
|
Hi !
Is There Help to Find the Maximum Value in A Row of A DataGridView .
Thanks In Advance !
|
|
|
|
|
No.
A DataGridView just holds Columns, it does not assume those Columns hold data types that are comparable amongst themselves.
|
|
|
|
|
You'll have to teach it how.
|
|
|
|
|
who's a good datagrid, here have a nice treat
|
|
|
|
|
DataGridView was not designed for data manipulation.
I would suggest you write an SQL query or Stored procedure that uses the MAX function and then call it with the Command.ExecuteScalar() method.
|
|
|
|
|
Quote:
You'll have to teach it how.
Yes , You are Right !
in fact I shouldn't to use any database , otherwise , it was simple than i want to do this now !
in any case I should do it with help u !
Regards !
|
|
|
|
|
Hi all! I am creating tab pages and adding them to a tab control. When setting the text for a tab page, the part of the tab page where the text is shown always stretches to show the full tab page title. But some of the titles are very long and would like to know how I can limit the width of the part of the control where the title is shown so that not all characters will be shown. I think this will enable the tab control to show more tab page titles at a time. Thanks in advance.
|
|
|
|
|
In a TabControl the functionality of the tabs themselves is very limited.
You have basically two choices:
1. create your own TabControl, giving you lots of headaches and full control.
2. modify the TabPage texts in accordance to the page being selected or not (that is what I would do). You could store the long and short texts in two separate Dictionary<TabPage,string> collections, and use the SelectedIndexChanged event to apply them.
|
|
|
|