Hello!
Why I cannot apply this operator to UINT or INT type in c# (VS 2005)?
uint MyConst;
uint SomeValue;
....
MyConst = MyConst & (!SomeValue)
Trying to erase certain bit inside MyConst. I come from Delphi world and the
translation would be
MyConst = MyConst and (not SomeValue)
where (not SomeValues) turns bits arround (0==>1, 1==>0)
How can the same thing be accomplished in c#?
best regards,
Jure 4 1980
On Oct 10, 9:20 am, "Jure Bogataj" <jure.boga...@mikrocop.comwrote:
Hello!
Why I cannot apply this operator to UINT or INT type in c# (VS 2005)?
uint MyConst;
uint SomeValue;
...
MyConst = MyConst & (!SomeValue)
Trying to erase certain bit inside MyConst. I come from Delphi world and the
translation would be
MyConst = MyConst and (not SomeValue)
where (not SomeValues) turns bits arround (0==>1, 1==>0)
How can the same thing be accomplished in c#?
best regards,
Jure
Hi Jure,
I think you want the bitwise operator ~ . Try something like this:
uint MyConst = 255;
uint SomeValue = 2;
MyConst = MyConst & ~SomeValue;
John
Jure Bogataj wrote:
Hello!
Why I cannot apply this operator to UINT or INT type in c# (VS 2005)?
uint MyConst;
uint SomeValue;
...
MyConst = MyConst & (!SomeValue)
Trying to erase certain bit inside MyConst. I come from Delphi world and the
translation would be
MyConst = MyConst and (not SomeValue)
where (not SomeValues) turns bits arround (0==>1, 1==>0)
How can the same thing be accomplished in c#?
I think you want "~", not "!", as per:
uint seven = 7;
uint four = 4;
uint threeihope = seven & ~four;
Console.WriteLine("result = " + threeihope);
Console.ReadLine();
HTH,
-rick-
Hi,
"Jure Bogataj" <ju**********@mikrocop.comwrote in message
news:uy*************@TK2MSFTNGP05.phx.gbl...
Hello!
Why I cannot apply this operator to UINT or INT type in c# (VS 2005)?
uint MyConst;
uint SomeValue;
...
MyConst = MyConst & (!SomeValue)
I think that the operator you are looking for is ~ :
MyConst = MyConst & (~SomeValue)
Thank you all for your replies! It works!
Best regards,
Jure
"Jure Bogataj" <ju**********@mikrocop.comwrote in message
news:uy*************@TK2MSFTNGP05.phx.gbl...
Hello!
Why I cannot apply this operator to UINT or INT type in c# (VS 2005)?
uint MyConst;
uint SomeValue;
...
MyConst = MyConst & (!SomeValue)
Trying to erase certain bit inside MyConst. I come from Delphi world and
the translation would be
MyConst = MyConst and (not SomeValue)
where (not SomeValues) turns bits arround (0==>1, 1==>0)
How can the same thing be accomplished in c#?
best regards,
Jure This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Beach Potato |
last post by:
Hi:
I've searched newsgroups and various archives, including MSDN & MFC sources,
but at this point failed to locate an accurate and simple implementation of
WndProc function for MSWindows window...
|
by: Ender |
last post by:
Let's assume you are developing a database application and you have an
ID field. You setup the ID field in the database as a 1 up increment
starting at zero.
Whenever I see programs, everyone...
|
by: Song Yun Zhao |
last post by:
Hi,
Just wondering what are the dis/advantages of using uint vs int. When
would be the best time to use it?
Personally I don't use uint that much, but I like to optimize my code
and make it...
|
by: Rohan Shah |
last post by:
i am looking for some simple matrix routines: vector*matrix,
matrix*matrix etc...in the form of code like the following that
multiplies two vectors:
void vmult(double* aa, double* bb, double*...
|
by: ±čŔçȲ |
last post by:
//this code generates the error.
uint a=1,b=2;
Console.WriteLine(a << b);
Console.WriteLine(a >> b);
What problem does "uint type" have.?
|
by: TT (Tom Tempelaere) |
last post by:
Hi people
I have a library built using MSVC6 which exports a method with the following signature
void library_method( UINT* sw_mode )
I am trying to use PInvoke to be able to call it from my...
|
by: muriwai |
last post by:
Hi,
I use C# 2.0 with the following:
object obj = ( int ) 1;
func( obj ); // Unboxing int to uint
void func( object obj )
{
|
by: alayle |
last post by:
This is the problem, i have a ocx, that have one control and one uint
Property, like this
Property color, acept values uint, Manually i set the value as this:
object.color = 0xFFFFFF;
for...
|
by: Tim Sprout |
last post by:
The P/Invoke Interop Assistant (http://www.codeplex.com/clrinterop)
generates a signature for GetDefaultPrinter using an uint type for
pcchBuffer:
public static extern bool GetDefaultPrinter(
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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: 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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |