Solved

C# operator

Posted on 2008-10-20
6
264 Views
Last Modified: 2013-12-17
Hi,
I want to use OR Operator  .. I am not getting it correctly

int KM = 0;
 rows[0]["StudentID"] =  rows[0]["studentID"]  | int.Parse(Km.ToString());  
0
Comment
Question by:dotnet0824
6 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
can you clarify what exactly you want to achieve? (ie not how)?
0
 
LVL 6

Expert Comment

by:xRalf
Comment Utility
Hello dotnet0824,

what do you want to do?

Regards,

xRalf
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 125 total points
Comment Utility
The or operator there would be doing a binary or http://en.wikipedia.org/wiki/Bitwise_operation

From looking I am not sure if this is what you actually want. Can you explain what you are hoping to have happen here?

Cheers,

Greg
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:dotnet0824
Comment Utility
yep ur right.. If checkBox is checked it takes the binary value
0
 
LVL 13

Expert Comment

by:TechTiger007
Comment Utility
Is rows[0]["StudentID"] integer?

int a = 100;
int b = 110;
int c = a|b;

this gives me 110 as expected.

Try changing your code to this


int val = Int32.Parse( rows[0]["studentID"]);

int val = val | KM;

rows[0]["studentID"] = Convert.ToString(val);


0
 
LVL 37

Expert Comment

by:gregoryyoung
Comment Utility
int Km = 0;
 rows[0]["StudentID"] =  rows[0]["studentID"]  | int.Parse(Km.ToString());  

this is the equivalent of a nop as Km is always 0... anything | 0 = anything

beyond that you could simplify this further with

rows[0]["StudentID"] |= Km;

assuming that rows[0]["StudentID"] is an integer which its impossible to tell from your code example.


Cheers,

Greg
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem with SqlConnection 5 109
Pass through dll 2 34
How to open a link from vb.net app 3 9
VB.NET HttpWebRequest 12 30
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now