I just read the top answer at this post:
http://stackoverflow.com/questions/374522/problem-inserting-string-or-null-into-sql-server-database
Correct me if I'm wrong, but can the ??-operator not only be used on two variables of the same type, if not I would greatly appreciate it, if anyone could solve my minor problem.
I tried to inser...
I often use ($var & 1) in my code, which returns true if $var is an odd number and false if it's an even number.
Just dawned on me that I have no idea what "&" actually does. Anyone care to explain?
...
Overloading the comparison operator, how to compare if the two variables points to the same object(i.e. not value)
public static bool operator ==(Landscape a, Landscape b)
{
return a.Width == b.Width && a.Height == b.Height;
}
public static bool operator !=(Landscape a, Landscape b)
{
return !(a.Width == b.Width && a.Height == ...
I know that the following is case sensitive:
if (StringA == StringB) {
So is there an operator which will compare two strings in an insensitive manner?
...
In this code:
Expression<Func<int, bool>> isOdd = i => (i & 1) == 1;
what is the meaning of (i & 1) == 1?
...
Basically here's the issue. All entities in my system are identified by their type and their id.
new Customer() { Id = 1} == new Customer() {Id = 1};
new Customer() { Id = 1} != new Customer() {Id = 2};
new Customer() { Id = 1} != new Product() {Id = 1};
Pretty standard scenario. Since all Entities have an Id I define an interface fo...
Does anyone have a exhaustive list of the names that C#/CLR gives to operators? (Maybe my lack of sleep is kicking in, but I can't seem to find it on Google) E.g. op_Addition, op_Subtraction. Furthermore is there any chance that these would be different in other cultures?
I am trying to create a class that can add/subtract etc. two obje...
I'm having the exciting task of finding out about VB.NET's <> and Not operators. Not - I'm assuming by my small use of it - is the functional equivalent of ! in languages such as C# and <> being equivalent of !=.
In VB.NET a common problem is doing Boolean expressions against objects that don't have a reference, it appears. So if we d...
Greetings everyone. I'm in need of some experiance here as how to deal with dynamic arrays with Objects.
I've a class 'SA', consisting of several objects 'Obj1', 'Obj2' etc...
Within the class I have a dynamic array 'SA_Array' which I initialize in the following manner where size sets its length:
double * SA_Array;
SA_Array = new doub...
Given the following code, will ixAdd do what you'd expect, i. e. return the value of ix before the increment, but increment the class member before leaving the function?
class myCounter {
private int _ix = 1;
public int ixAdd()
{
return _ix++;
}
}
I wasn't quite sure if the usual rules for post / pre increment...
It would be really nice if C# allowed an ??= operator. I've found myself writing the following frequently:
something = something ?? new Something();
I'd rather write it like this:
something ??= new Something();
Thoughts? New language extensions are always controversial by their nature.
...
In PHP you can use square brackets on an element to access attributes:
$node = /* SimpleXMLElement */
$id = $node['id'];
What's weird is that $id isn't a string, It's another SimpleXMLElement. Why isn't it a string? I find myself using strval() all over the place on this.
How are the square brackets working? Can I do that with my own...
In other contexts I know this << is called the bitshift operator. Is there a name for it when it's just used for append operations like you would do in an array or string (not sure what else you can append with it)?
I'd like to be able to use an English word to refer to it instead of saying "you know, the operator with the two left arro...
I want to check whether a value is equal to 1. Is there any difference in the following lines of code
Evaluated value == 1
1 == evaluated value
in terms of the compiler execution
...
Hello,
the line "if(arg2 & 1)" in C++(arg2 is DWORD) is equal to "if(arg2 & 1==0)" in C#(arg2 is Uint32),right?
I am trying to translate a function from C++ to C#,but I get an error:
Operator '&' cannot be applied to operands of type 'uint' and 'bool'
I'd be also thankful if you could see further in the whole function for any other ...
What is the purpose and effect of the true and false operators in C#? The official documentation on these is hopelessly non-explanatory.
...
More specifically, is there a set of values ( a, b and c) for which the operator precedence matters in the statement:
var value = (a && b == c);
(with the exception of NaN).
...
I'm writing .NET On-the-Fly compiler for CLR scripting and want execution method make generic acceptable:
object Execute()
{
return type.InvokeMember(..);
}
T Execute<T>()
{
return Execute() as T; /* doesn't work:
The type parameter 'T' cannot be used with the 'as' operator because
it does not have a class type constraint nor a...
Here is the code I am looking at.
foreach ($header as $idx => $field) {
if (stripos($field, 'foo') !== false) {
$cols['foo'] = $idx;
} else if (stripos($field, 'bar') !== false) {
$cols['bar'] = $idx;
} else if (stripos($field, 'brr') !== false) {
$cols['brr'] = $idx;
} else if (stripos($field, '...
Is there any more convenient way to compare a tuple of data in T-SQL than doing something like this:
SELECT TOP 100 A, B
FROM MyTable
WHERE (A > @A OR (A = @A AND B > @B))
ORDER BY A, B
Basically I'm looking for rows with (A, B) > (@A, @B) (the same ordering as I have in the order by clause). I have cases where I have 3 fields, but it...