Possible Duplicate:
least astonishment in python: the mutable default argument
Can you help me understand of the behaviour and implications of the python __init__ constructor. It seems like when there is an optional parameter and you try and set an existing object to a new object the optional value of the existing object is p...
how i can set default value for DateTime in optional parameter?
public SomeClassInit(Guid docId, DateTime addedOn = DateTime.Now???)
{
//Init codes here
}
...
I'm translating an API from C to C#, and one of the functions allocates a number of related objects, some of which are optional. The C version accepts several pointer parameters which are used to return integer handles to the objects, and the caller can pass NULL for some of the pointers to avoid allocating those objects:
void initializ...
Today I had something weird happen in my copy of Resharper 5. I have a class that looks like this:
public class Foo
{
public string Username { get; private set; }
public Foo (string userName) { Username = userName; }
public void Bar()
{
DoWork(Username);
}
public void DoWork(string userName) { }
}
W...
I am working with some code that has seven overloads of a function TraceWrite:
void TraceWrite(string Application, LogLevelENUM LogLevel, string Message, string Data = "");
void TraceWrite(string Application, LogLevelENUM LogLevel, string Message, bool LogToFileOnly, string Data = "");
void TraceWrite(string Application, LogLevelENUM L...
Hello,
I am updating some super legacy code and I am unsure how to make this HTML5 compatible.
<option value='<a href='http://localhost:8080/dm?id=&#037;&#037;SUBSCRIBER_ID_TAG&#037;&#037;'>View in a browser window</a>'>Display Message(HTML Version)</option>
I personally have never run across something like that so...
I do not understand the behavior of the present() intrinsic function with pgf90 7.2. I wrote a 20 line sample program to test this, but the results still make no sense to me. Observe:
subroutine testopt(one,two,three,four,five)
implicit none
integer, intent(in) :: one,two
integer, intent(out) :: three
integer, intent(in), o...
Is it possible to use optional parameters (and other purely-syntactical C# 4.0 features) in Windows Phone XNA applications?
I've read and heard conflicting information about this. In the Advanced Build Settings for my application, the Language Version is set to C# 3.0 (C# 4.0 is not available in the Language Version drop-down list). Is ...
Im writing a parser than can parse expressions like myfunc1(), myfunc2(param1) and myfunc3(param1, param2) (with an unknown amount of parameters). Now I'm trying to get my parse expressions right. I'm using the Lemon Parser Generator. Here is what I've come up with:
application(res) ::= APPLICATIONNAME(a) BRACE_OPEN params BRACE_CLOSE. ...
Hello :)
I have a parameter that provides a dropdown list in the report, and I would like to make it optional, that is, I want a report to run even if I don't select anything from the list, and to have a Null checkbox next to it, that regulates if the parameter is optional or not. The parameter is declared in stored procedure and is = n...
This piece of code compiles OK in VS 2010 in a framework 3.5 project (I triple checked that)
public LoggingClient(string uri = "net.msmq://localhost/logging"){...}
Why? I see nothing in the C# 4 spec (doc version), section 21.1, that says this should be backwardly compatible. How is it that I get no compilation error? Will this fa...
public ClassType(string type) {
Type = type;
}
public ClassType(string type,bool isArray=false) {
Type = type;
IsArray = isArray;
}
ClassType ct = new ClassType("adsf");
Which constructor is chosen?
...
Hello,
I use libexif in my C/gtk+ application. But i want to make it optional. What must i to write in my configure file for to do this?
Thank you
...
I am curious to know that whether optional parameter introduced in C#4 is backward compatible or not?
Let me clarify my question with a simple example. Suppose I write the following code in C#4 on .Net2 in VS2010:
public void Foo(int val1, int val2, int val3 = 5){ .... }
Now I compiled the code, make a dll and reference it to a C#2 /...
which one is better? at a glance optional parameter seems better (less code, less XML documentation, etc), but why do most MSDN library classes use overloading instead of optional parameters?
Is there any special thing you have to take note when you choose to use optional parameter (or overloading)?
...
I hope to load .net dll in ironpython.
But one of static functions in .net dll, has some Named and Optional Arguments.
like, Draw(weight:w,height:h, Area=1)
Only can I use full arguments?
...
Hi Guys,
Here's my method:
public void SomeQuery(string email = "", Guid userId = Guid.Empty)
{
// do some query
}
userId is giving me an error as it must be a compile-time constant, which i understand. But even when i declare a const:
private const emptyGuid = Guid.Empty;
then change the method signature to:
public void SomeQ...
I am creating a stored procedure to do a search through a table. I have many different search fields, all of which are optional. Is there a way to create a stored procedure that will handle this? Let's say I have a table with four fields: ID, FirstName, LastName and Title. I could do something like this:
CREATE PROCEDURE spDoSearch...
MSDN's VS2010 Named and Optional Arguments (C# Programming Guide) tells us about optional parameters in C#, showing code like I'd expect:
public void ExampleMethod(int required
, string optionalstr = "default string"
, int optionalint = 10)
Ok, but it also says:
You can also decl...