Never mind. I stumbled on ==.
Can someone point me to a simple-minded intro to C#? I had searched MSDN
and Google for the answer to this, and I found a long list of c# operatiors
somewhere, but I simply couldn't understand the explanations - I'm not a
computer science guru - more of a self taught try-it person.
> Never mind. I stumbled on ==.
>
> Can someone point me to a simple-minded intro to C#? I had searched MSDN
> and Google for the answer to this, and I found a long list of c# operatiors
> somewhere, but I simply couldn't understand the explanations - I'm not a
> computer science guru - more of a self taught try-it person.
Try these:
http://www.softsteel.co.uk/tutorials/cSharp/cIndex.html
http://www.publicjoe.f9.co.uk/csharp/csharp.html
Have you download the C# spec from here?
http://msdn.microsoft.com/netframework/programming/clr/default.aspx
chanmm
> Never mind. I stumbled on ==.
>
[quoted text clipped - 23 lines]
>>
>> return ReturnCode.FAILURE;
Not sure if you are still stuck but:
"if (ERPHostId != null)
returnXML = "<ERP></ERP>";
return ReturnCode.FAILURE;"
should be
if (!(ERPHostId == null))
{
returnXML = "<ERP></ERP>";
return ReturnCode.FAILURE;
}
i found != to not act as i would expect in c# so i do it the above way. If
ERPJostId is a string as you say then i presume you intialise this somewhere
like:
string ERPHostId = "";
if so then test it is still "" instead of checking for null, because unless
some method sets it to null it will just remain blank. so in that case:
if (!(ERPHostId.Equals("")))
{
returnXML = "<ERP></ERP>";
return ReturnCode.FAILURE;
}
returnXML will get set to that string value, i don't see why it wouldnt in
the above statement. However i noticed your code sample is missing the
braces {}, i presumed this was just how you posted it but your actual code
has it in? If your actual code doesn't then put them in as above if that is
that you want all that code to be within the if statement.
If there are other basics your stuck on feel free to email me direct or
reply on here.
> Never mind. I stumbled on ==.
>
[quoted text clipped - 23 lines]
>>
>> return ReturnCode.FAILURE;
Joanna Carter [TeamB] - 29 Sep 2006 09:50 GMT
| "if (ERPHostId != null)
| if (!(ERPHostId == null))
There is absolutely no difference between these two statements
| i found != to not act as i would expect in c# so i do it the above way. If
| ERPJostId is a string as you say then i presume you intialise this somewhere
| like:
|
| string ERPHostId = "";
You can also initialise a string like this :
{
string ERPHostId = null;
but you could not do :
{
string ERPHostId;
if (ERPHostId == null)
...because ERPHostId is uninitialised.
| if so then test it is still "" instead of checking for null, because unless
| some method sets it to null it will just remain blank. so in that case:
In C#, strings can be either null or any empty string, so any test that
wants to know whether a string has any content must do both tests.
{
if (!(ERPHostId == null))
...will only test that a string is null, it will not guarantee that the
string is empty.
{
if (ERPHostId != null && ERPHostId != String.Empty)
...
Now, and only now have you safely got a string that has content.
Joanna

Signature
Joanna Carter [TeamB]
Consultant Software Engineer
Jon Skeet [C# MVP] - 29 Sep 2006 19:10 GMT
> Not sure if you are still stuck but:
>
[quoted text clipped - 15 lines]
>
> i found != to not act as i would expect in c# so i do it the above way.
No, != should work absolutely fine here - and is more easily readable.
Could you post a short but complete program which demonstrates != not
working properly?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
> if so then test it is still "" instead of checking for null, because unless
> some method sets it to null it will just remain blank. so in that case:
[quoted text clipped - 5 lines]
> return ReturnCode.FAILURE;
> }
That's more easily readable as:
if (ERPHostId != "")

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Daniel - 29 Sep 2006 19:52 GMT
Sorry my bad, i was super tired when i wrote the reply, i use != in my code
lol.
>> Not sure if you are still stuck but:
>>
[quoted text clipped - 38 lines]
>
> if (ERPHostId != "")