|
Globel variable doesn't exist in C#. that is true. But if you want to access a variable Globally. what you will do ?
i have clear idea that how i can use a variable globally in C#. app.config
" dear friend you forgot this ".
Sreejith S S Nair
|
|
|
|
|
Globel variable doesn't exist in C#. that is true. But if you want to access a variable Globally. what you will do ?
i have clear idea that how i can use a variable globally in C#. app.config
" dear friend you forgot this ".
Sreejith S S Nair
|
|
|
|
|
Does anybody know if a c# program can run in 64 bit mode on Windows XP 64bit edition or Windows server 2003 64bit. I have some customers that have AMD Athlon 64 and asking me!
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|
|
Dimitris Iliopoulos wrote:
Does anybody know if a c# program can run in 64 bit mode on Windows XP 64bit edition or Windows server 2003 64bit. I have some customers that have AMD Athlon 64 and asking me!
I'll take a stab at this--no, I don't think it will run in 64 bit mode. The JIT compiler doesn't know about 64 bit mode yet, and I don't think the .NET dll's are 64 bit capable either.
Of course, it'll still run fine, but in 32 bit mode.
Marc
Microsoft MVP, Visual C#
MyXaml
MyXaml Blog
|
|
|
|
|
64 bit support won't show up until VS.NET 2005 and the .NET Framework 2.0. Exactly how much support remains to be seen though because not every technology Microsoft has will be 64-bit ready at the time the .NET Framework 2.0 and compilers are released.
Your app will run just fine as it is now on a 64-bit system.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Hi,
If I call a web service and I can't connect to it for whatever reason, what exception will it call? From my reading it sounds like a SoapException error but not sure. If so what reference do I need in order to catch this SoapException?
Thanks,
JJ
|
|
|
|
|
It doesn't have to be a SoapException. The call could also throw a SecurityException, a custom exception thrown by the Web Method, ArgumentOutOfRange, ... ASP.NET could throw an exception. A SoapException is just one class of exceptions that could be thrown.
Your call to the WebMethod should be wrapped in Try/Catch/Finally blocks:
Try
Dim result As Integer = remoteClass.WebMethodCall(parameters)
Catch soapFailure As SoapException
' Code to execute in response to a SoapException
Catch soapFailure As SoapHeaderException
' Code to execute in response to a SoapHeaderException
Catch argFailure As ArgumentOutOfRange
' Code to execute if the args are out of whack.
' Which they shouldn't be if your doing validation! ;)
Finally
' This code will execute no matter what happens in the Try and Catch blocks...
End Try
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi Dave,
I can't seem to find the ArgumentOutOfRange exception in c#, any ideas where its referenced from?
Thanks for replying,
JJ
|
|
|
|
|
Sorry, it's ArgumentOutOfRangeException and it derives as follows:
System.Exception.SystemException.ArgumentException.ArgumentOutOfRangeException
or just:
System.ArgumentOutOfRangeException
for short.
BTW: That's not the only Argument exception that can be thrown and writing seperate exception handlers for each and every class is VERY inefficient. You might want to handle entire classes of exceptions such as SoapException covers all SOAP failures with the body of the SOAP message. SoapHeaderException covers all those in parsing the SOAP header. Like I said, there a BUNCH of exceptions that can be thrown and handling all of them is not necessarily a good idea. You might want to read this[^] article on MSDN for an idea of how to handle unexpected failures.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi, though I've been a member of this site for some time now I've not posted in the forums very often. Well, finally I've got a question that I couldn't answer in any other way (Including reading several books and asking for the assistance of some of my teachers in the MCAD).
According to the OO Programming model, every class attribute has to be marked as private and be made accessible to other classes throgh a Property. Now, in my class designs, I work a lot with ArrayLists as member of classes, so (and here comes the question)...
How can I create a property for an ArrayList? Is it done trough Indexers? (The same could be asked about arrays and any collection that belongs to a class, like Stacks, Qeues, Hash Tables, etc.).
Thanks for reading so far, I'd like to hear what you think about it.
morph3us
~~~~~~~~
only the phoenix arises
and does not descend
and everything changes
and nothing is truly lost
|
|
|
|
|
If you would like to provide a property for a ArrayList , just make the property return a ArrayList .
Simple.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
CWIZO wrote:
If you would like to provide a property for a ArrayList, just make the property return a ArrayList.
Yes, I know that could be an approach, but the problem is I want to treat my properties as they were attributes (The property is a wraper method for an attribute).
morph3us
~~~~~~~~
only the phoenix arises
and does not descend
and everything changes
and nothing is truly lost
|
|
|
|
|
Use Indexers, IMO.
And I don't agree that every attribute should be marked private. Makes inheritence pointless, when the derived class should be allowed to access the field directly, instead of through a property. I mark all my fields protected.
Marc
Microsoft MVP, Visual C#
MyXaml
MyXaml Blog
|
|
|
|
|
Marc Clifton wrote:
I mark all my fields protected.
Ouch! That can turn into an inheritance mess And then you need to add extra public methods/properties to expose certain features of it, no thanx mate
top secret xacc-ide 0.0.1
|
|
|
|
|
I have to agree with Marc in general. An indexer is the better way to go. Saying that, let me contradict myself:
1. If an indexer "makes sense" in the class you're talking about, it is the way to go. That is, a construct dealing with "Dog" for example, probably should not have an indexer that accesses it's meals for the week.
2. If #1 does not apply, you may be better off breaking our the arraylists into seperate classes if need be, or providing access to the ArrayList as a property, like "Dog.Meals[Monday]" or somesuch.
Jeremy Kimball
Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.
(I have a catapult. Give me all the money, or I will fling an enormous rock at your head)
|
|
|
|
|
Yes, I agree. Retruning arraylist is bad idea in most cases. Even if you have readonly property for your arraylist, users can still do: object.myList.Clear() and wipe out all the data.
If you want only readonly access to the array list, you can use readonly wrapper:
public ArrayList MyList
{
get { return ArrayList.ReadOnly(myInternalArrayList); }
}
any changes on the resulting list will throw exception. No elements are copied.
To bad c# does not support named indexers. That way you could do:
Dog.Meals[Monday] without having Meals another property that is a list.
|
|
|
|
|
I known it very easy in ADO,but I don’t know hot to do it in ADO.net.
THK u!
|
|
|
|
|
See a prevoius discussion[^] about this. You'd want to modify the query slightly like so:
SELECT Name
FROM MSysObjects
WHERE Type = 1 AND NOT Name LIKE "MSys%" IIRC, you need to be an Admin for the database to perform this query.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you,Your answer id what I need.
SELECT *
FROM MSysObjects
WHERE Type = 1 AND Left(Name,4) <> "MSys";
Thank you
|
|
|
|
|
class MyClass
{
public void Foo(const int param)
{
}
} This type of statment works perfectly well in C++, but a const param seems to confuse the C# compiler a bit. It says "Type Expected". How is it possible pass a constant / read only parameter in C#?
Joel Holdsworth
Wanna give me a job over the summer?
View my online CV and Job Application[^]
|
|
|
|
|
const is not allowed in the parameter list. You should read the C# Language Specification[^]. IIRC, a constant parameter declaration isn't even allowed by the CLI (Common Language Infrastructure).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Putting /*[in]*/ before each parameter seems to stop them being changable at compile time
e.g.
public void foo( int foo)
{
} - but I get the impression that this is a bit of a cludged way of getting the results. I think I'll just rethink how I do this.
Joel Holdsworth
Wanna give me a job over the summer?
View my online CV and Job Application[^]
|
|
|
|
|
Interesting if true; I've never seen that documented. It would definitely be a compiler feature, though, and have no bearing in the actual code.
Keep in mind that an Int32 is a value type and is therefore passed by value. This won't prevent your code from changing it, but if your method implementation does it won't affect the variable that was passed to you (if a variable was indeed passed to your method). Since your method isn't virtual (and hence can't be overridden), just make sure you don't change it. I know that's not a lot of protection, but declaring an argument as constant is really just to avoid future headaches if you forget that you shouldn't change it, IMO.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Well actually it's not an Int32 - its actually an object which I cooked up myself.
Still it seems a bit wierd to not allow const or readonly parameters because, just as you say, they always help me avoid playing around with data which should be left untouched!
Joel Holdsworth
Wanna give me a job over the summer?
View my online CV and Job Application[^]
|
|
|
|