Click here to Skip to main content
16,007,885 members
Home / Discussions / C#
   

C#

 
GeneralRe: Pressing DELETE button in DataGrid Pin
Paul Riley2-Apr-03 7:50
Paul Riley2-Apr-03 7:50 
GeneralRe: Pressing DELETE button in DataGrid Pin
Mazdak2-Apr-03 7:53
Mazdak2-Apr-03 7:53 
GeneralRe: Pressing DELETE button in DataGrid Pin
Mazdak2-Apr-03 9:06
Mazdak2-Apr-03 9:06 
GeneralRe: Pressing DELETE button in DataGrid Pin
Mazdak2-Apr-03 9:34
Mazdak2-Apr-03 9:34 
QuestionC# Bitwise Operators? Pin
eidylon2-Apr-03 5:00
eidylon2-Apr-03 5:00 
AnswerRe: C# Bitwise Operators? Pin
James T. Johnson2-Apr-03 5:51
James T. Johnson2-Apr-03 5:51 
GeneralRe: C# Bitwise Operators? Pin
eidylon2-Apr-03 7:49
eidylon2-Apr-03 7:49 
GeneralRe: C# Bitwise Operators? Pin
James T. Johnson2-Apr-03 8:45
James T. Johnson2-Apr-03 8:45 
whosit wrote:
Any explanations or ideas why this is?

I can't think of any reasons, but a quick test shows that what we know of as bitwise logic is what C# uses.

[Flags()]
public enum Enum
{
	A = 1,
	B = 2,
	C = 4,
	D = A | B,
	E = 8,
	F = 64
}
 
[STAThread]
static void Main(string[] args)
{
	Enum e = Enum.A;
	Console.WriteLine("e = {0}", e);
 
	e = Enum.A | Enum.C;
	Console.WriteLine("e should equal (A):  e = {0}", e);
 
	if( (e & Enum.A) == Enum.A )
		Console.WriteLine("Enum.A is set");
	else
		Console.WriteLine("Enum.A isn't set");
 
	e = (e | Enum.B);
	Console.WriteLine("e should (A, B, C) or (D, C):  e = {0}", e);
 
	if( (e & Enum.C) == Enum.C )
		Console.WriteLine("Enum.C is set");
	if( (e & Enum.B) == Enum.B )
		Console.WriteLine("Enum.B is set");
	if( (e & Enum.A) == Enum.A)
		Console.WriteLine("Enum.A is set");
 
	e = e | Enum.E;
 
	if( (e & Enum.E) == Enum.E)
		Console.WriteLine("Enum.E is set - correct usage");
	if( (e | Enum.E) == Enum.E)
		Console.WriteLine("Enum.E is set - incorrect usage");
 
	e = e & (~Enum.E);
	Console.WriteLine("e should be (A, B, C) or (D, C)...e was unset: e = {0}", e);
 
	Console.ReadLine();
}
The output should be:
e = A
e should equal (A):  e = A, C
Enum.A is set
e should (A, B, C) or (D, C):  e = D, C
Enum.C is set
Enum.B is set
Enum.A is set
Enum.E is set - correct usage
e should be (A, B, C) or (D, C)...E was unset: e = D, C
Now as to the next part...

whosit wrote:
Then what threw me off even more was a line (unchanged) in GetItemData which reads:
if(((FileAttributes)pscd.dwFileAttributes|FileAttributes.Directory)==FileAttributes.Directory)
Where the original author is checking the flag with an OR.


The code above would work, so long as pscd.dwFileAttributes had either no flags set or just the FileAttributes.Directory flag set, in which case the bitwise-or effectively does nothing and the check continues to work.

Doing a quick test if I change the | to the proper & it still works as expected, and taking a look at some directories I can't find any that don't report to contain some read-only files, even dirs with no files in them. Trying to change that (by unchecking readonly in the dir properties box) has no effect.

James

"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation

GeneralRe: C# Bitwise Operators? Pin
eidylon2-Apr-03 8:54
eidylon2-Apr-03 8:54 
GeneralRe: C# Bitwise Operators? Pin
James T. Johnson2-Apr-03 9:03
James T. Johnson2-Apr-03 9:03 
GeneralRe: C# Bitwise Operators? Pin
eidylon2-Apr-03 9:08
eidylon2-Apr-03 9:08 
GeneralRe: C# Bitwise Operators? Pin
Roger Alsing2-Apr-03 22:09
Roger Alsing2-Apr-03 22:09 
Generaljavascript not working in webbrowswer control Pin
monrobot132-Apr-03 4:22
monrobot132-Apr-03 4:22 
GeneralRe: javascript not working in webbrowswer control Pin
Stephane Rodriguez.2-Apr-03 19:40
Stephane Rodriguez.2-Apr-03 19:40 
GeneralRe: javascript not working in webbrowswer control Pin
monrobot133-Apr-03 3:12
monrobot133-Apr-03 3:12 
GeneralRe: javascript not working in webbrowswer control Pin
Stephane Rodriguez.3-Apr-03 3:19
Stephane Rodriguez.3-Apr-03 3:19 
GeneralC# Dynamic Assembly Pin
anders2-Apr-03 4:15
anders2-Apr-03 4:15 
GeneralRe: C# Dynamic Assembly Pin
Oleksandr Kucherenko3-Apr-03 5:01
Oleksandr Kucherenko3-Apr-03 5:01 
Question.net Attributes? Pin
Roger Alsing2-Apr-03 0:54
Roger Alsing2-Apr-03 0:54 
AnswerRe: .net Attributes? Pin
Nick Parker2-Apr-03 4:42
protectorNick Parker2-Apr-03 4:42 
GeneralActive Directory - Users or whatever Pin
Velichko Sarev2-Apr-03 0:02
Velichko Sarev2-Apr-03 0:02 
GeneralRe: Active Directory - Users or whatever Pin
Mazdak2-Apr-03 7:49
Mazdak2-Apr-03 7:49 
GeneralRe: Active Directory - Users or whatever Pin
wangzhibin2-Apr-03 14:30
wangzhibin2-Apr-03 14:30 
GeneralC# and CVS Pin
se99ts1-Apr-03 22:58
se99ts1-Apr-03 22:58 
Questionhow to program with c# for exchange 2000 Pin
wangzhibin1-Apr-03 22:38
wangzhibin1-Apr-03 22:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.