|
Ah, structs. God love them. Because I can't.
Why am I getting the compiler error:
Field 'foo.myInts' must be fully assigned before control leaves the constructor.
For this code:
public struct foo<br />
{<br />
public readonly List{{int}} myInts;<br />
<br />
public foo(int unususedInt)<br />
{<br />
List{{int}} myInts = new List{{int}}();<br />
myInts.Add(1);<br />
}<br />
}
Where {{ and }} are really angle brackets, but HTML can't handle that.
If it's complaining about the Default Constructor - well, I don't have any control over that, and I have no idea how the compiler is intializing myInts. And in the public constructor, I am clearly assigning myInts.
What exactly is it complaining about?
|
|
|
|
|
public struct foo<br />
{<br />
public readonly List myInts;<br />
<br />
public foo(int unususedInt)<br />
{<br />
List myInts = new List();<br />
myInts.Add(1);<br />
}<br />
}
only two letters away from being an asset
|
|
|
|
|
Thanks. It took me a second to see what you had changed . I was about to reply with "Ummm... what?"
Man, I wish the compiler error was less ambiguous here. It seems more like the foul was declaring myInts twice, not that it was unassigned.
|
|
|
|
|
JoeRip wrote: seems more like the foul was declaring myInts twice, not that it was unassigned.
No, the problem was that the member variable was unassigned. You created an instance that was scoped only to the constructor.
only two letters away from being an asset
|
|
|
|
|
But shouldn't there have been a name collision? The name was already declared as a field, and accessible at the constuctor level.
|
|
|
|
|
The variable in the constructor is scoped locally and overrides the one declared at the struct level.
It is a good practice to use properties to access member variables, and not make them public. Also, the practice of naming members variables with either m_ or _ (underscore) would alert you to this type of error.
only two letters away from being an asset
|
|
|
|
|
Can any one tell me how to run an EXE through windows service.
Thanks in Advance.
|
|
|
|
|
What do you mean? Do you mean how to create a Windows service, or do you mean how to run an exe from a Windows service?
only two letters away from being an asset
|
|
|
|
|
How to run an exe from a windows service?
|
|
|
|
|
Have you had a look at Process.Start method ?
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
use System.Diagonistic and create a process class object and give thhe process file name as your exe and start it !!!!
|
|
|
|
|
Yes i tried with this method, but no result
|
|
|
|
|
can you explain exactly what do you want ?
|
|
|
|
|
Abhijit Jana wrote: can you explain exactly what do you want ?
Might be this is one other form of code solicitation?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
Reddy Prakash wrote: but no result
What do you mean? Did it crash with any exceptions?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
|
have remoting with events working on a single machine, but... when I put the
> server, client, and remote object on a 2nd machine.... things do not work
> completely.. So basically I have the same 3 directories (Client, Server,
> RemoteObject) on two machines. I run the server on machine1, the client on
> machine2... Now client indeed has access to the remote object... and the
> client does call a function on that remote object... as the console for the
> server writes out a msg when it gets a request...
>
> public void BroadCastMessage(string msg)
> {
> IAsyncResult ar;
>
> Console.WriteLine("Raising EventHandler1");
>
> System.Delegate[] invkList = EventHandler1.GetInvocationList();
> IEnumerator ie = invkList.GetEnumerator();
> while(ie.MoveNext())
> {
> RemotingObject.EventHandlerDelegate handler =
> (RemotingObject.EventHandlerDelegate)ie.Current;
> try
> {
> ar = handler.BeginInvoke(msg,null,null);
> }
>
> upon calling BeginInvoke, it sits for a second or three... but nothing on
> the client occurs...
>
> Now if I ran the client & server on the same machine, things work....
>
> any clues please....
|
|
|
|
|
Hi All,
I am working on a project that uses a browser control. Browser control was working fine till I use Append Child to insert anchor element into document. Problem is when page finish loading, ScrollBar in browser control scrolls down automatically and shows the bottom of the web page. I don't want scrollbars to scroll down automatically because I want show the top of the page. Pleaase help.
Thanks,
A.Asif
|
|
|
|
|
One post is enough
only two letters away from being an asset
|
|
|
|
|
Second post was a mistake.
A.Asif
|
|
|
|
|
Hi All,
I am working on a project that uses a browser control. Browser control was working fine till I use Append Child to insert anchor element into document. Problem is when page finish loading, ScrollBar in browser control scrolls down automatically and shows the bottom of the web page. I don't want scrollbars to scroll down automatically because I want show the top of the page. Pleaase help.
Thanks,
A.Asif
|
|
|
|
|
Is there a way to set a named line or elipse, instead of just drawing one? If so, how would I do this. Thanks.
- "Achieving all knowledge does not mean achieving all wisdom."
- "What makes you smart
?"
|
|
|
|
|
If you mean how do you draw a graphics object and be able to select it at runtime, no, there isn't any method built in to do this. There is no "retained mode" graphics in GDI+, only "immediate mode". You have to write the code to do this yourself. Google for "gdi retained mode".
|
|
|
|
|
Hi All,
I'm fetching web pages, and parsing TITLE to gather information. The title will come back as:
<TITLE>OID Repository - {iso(1) identified-organization(3) dod(6) internet(1)}</TITLE>
For some reason, my RE will not remove the trailing '}' from the match. The pattern is as follows (sorry about the poor formatting - I had to get rid of the smiley faces):
String Pattern = @"(?<=<title.*>)*(?<={)([\s\S]*)(?<=})*(?=</title>)";
Any ideas?
Jeff
Jeffrey Walton
|
|
|
|
|
The following expression removes the trailing '}' from the match.
(?<=<title.*>)*(?<={)([\s\S]*)(?=})
The problem with your expression is that the [\s\S]* subexpression matches the trailing '}' character and includes it in the match. The regex engine then moves to the following character. The zero-width positive lookbehind assertion (?<=})* successfully matches the preceding character, which is the '}', and the final zero-width positive lookahead assertion is also successful.
Adding the trailing '}' character to the zero-width positive lookahead assertion achieves the correct result because after matching the final parenthesis the regex engine looks forward and finds that the trailing '}' and every following character match this assertion, but doesn't include them in the match.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|