|
XajniN wrote: The only thing you can do
Not at all; that may be recommended, but there are several ways to skin this cat.
Database, config file, resource file (as far as I know), an enumeration may be of use too.
|
|
|
|
|
Well, that's one of the things you'll have to get used to with C#.
I usually define a Global class that contains all my constants and true global variables. Just reference it and use the constants/variables or refer to them as Global.Foo , etc.
Perhaps others have a more elegant way.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Ooor... pass your C# code through a C-preprocessor; there's nothing stopping you.
|
|
|
|
|
I knew I would read such a reply by you right when I saw the question.
|
|
|
|
|
Hey guys
thanks for all ur suggestions.
Prithaa
|
|
|
|
|
Yep, I almost expected someone to have already replied saying just wait until I got on.
|
|
|
|
|
Any sugestions on a very extensive book on everything C#? The C# bible is good, but outdated...last printing was in 2002. Im looking fore something like that.
|
|
|
|
|
I often refer to the spec.
|
|
|
|
|
You can hardly find any book that will cover almost everything. MSDN Library is the best place to start.
|
|
|
|
|
"Everything C#", is MSDN.
If you want something else, then you're going to have to put up with stuff being left out.
|
|
|
|
|
The Nutshell[^] book(s). Accept no substitute!
/ravi
|
|
|
|
|
is it possible to use an XML file with all XML assemblies but with an XML which has a different file extension? so it's actually an XML file but it has .ext extension?
|
|
|
|
|
It depends upon what you mean by "use", but you can read any file containing XML as XML, no matter what the extension of the file actually is.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
|
It depends on what you want it to do based on the extension. I use XML to save configuration info in files and give the file a different extension so they are easy to identify, etc. The file extension and the contents are independent of each other.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
I want to know how can I check if the clipboard has a URL or not? basically I have a txtURL textbox on my form and I want if they user went to any browser or word editor to copy a URL from there then came back o the same form it should display a MessageBox saying dio you want to copy the URL in the textbox?
|
|
|
|
|
Yeah, just check if the text in the clipboard is a valid URL. I don't believe there is a specific format for URL's when copied to the clipboard (i.e., they will just be copied as text). Actually, the way the clipboard works is that items can be copied to the clipboard in their various formats. So, the URL might exist as both text and as, say, HTML in the clipboard. If you really want to know, give it a try... handle some event that inspects the clipboard and see what formats are in it, then see what data is contained in each format.
|
|
|
|
|
Get the text from the Clipboard using the GetText method then match it against a URL regular expression.
Eslam Afifi
|
|
|
|
|
Hi,
I have a function like foo(ref System.Windows.Form objForm) and I need to pass a custom form which is derived from System.Windows.Form that is
Custom form :- FormX : System.Windows.Form
So, my question is how can I call function foo with object of FormX as ref argument that is something like
FormX obj;
foo (ref obj); // it is giving compilation error
Please let me know the solution
Regards,
Pankaj Sachdeva
There is no future lies in any job but future lies in the person who holds the job
|
|
|
|
|
You haven't stated the error but I guess it's because you haven't assigned obj to either null or a FormX instance.
When passing by reference the object is passed into the function so it must exist (or be assignd null if a reference type).
If you want the function to pass out the FormX instance and not provide it to the method yourself, you should use out instead of ref .
By the way, unless you've messed with the System.Windows namespace, it should be System.Windows.Forms.Form .
Dave
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Pass-by-reference parameters must match type exactly. The workaround is
to do:
FormX objX = new FormX();
Form obj = objX;
foo(ref obj);
However, since FormX is a reference type, your foo method doesn't even need the ref parameter keyword. c# passes it as a reference by default.
foo(System.Windows.Forms.Form obj)
{
}
|
|
|
|
|
Member 2463256 wrote: However, since FormX is a reference type, your foo method doesn't even need the ref parameter keyword. c# passes it as a reference by default.
Not quite the same thing. The difference is this:
foo(ref Form obj)
{
obj = new Form();
}
foo(Form obj)
{
obj = new Form();
}
The "ref" keyword is similar to the "out" keyword, except that "out" only works in one direction, while "ref" both provides a value and allows it to be changed.
Of course, in either case, using "ref" or not, changing a property of 'obj' will affect the caller's instance.
|
|
|
|
|
Ian Shlasko wrote: except that "out" only works in one direction, while "ref" both provides a value and allows it to be changed.
Not quite. The only difference between ref and out is that out ensures the value will be set before you return from the method. When ref is used, it does not ensure the variable will be set... it merely allows it. This allows for one to do something like this:
Form myForm;
SomeMethod(out myForm);
myForm.ShowDialog();
Notice how this differs from ref:
Form myForm;
SomeMethod(ref myForm);
myForm.ShowDialog();
|
|
|
|
|
Well, your example illustrates the inverse, but still, I stand corrected. Forgot about the requirement that "out" variables are set.
But basically...
Normal: Values in, unmodified (Aside from setters/methods of object types)
Ref: Values in, possibly different values out
Out: Nothing in, values out
|
|
|
|
|
Thank you everybody but in my case Member 2463256 reply was useful. Problem resolved!
Regards,
Pankaj Sachdeva
There is no future lies in any job but future lies in the person who holds the job
|
|
|
|