|
Sorry, I misread the first time....
Since those fields are readonly in addition to your list, you need to set them in the a constructor of the frog struct. You might try adding something like the following to your frog struct.
public frog(int legs, int eyes)
{
this.legs = legs;
this.eyes = eyes;
}
so your entire program would look like....
public struct foo
{
public readonly List<frog> al;
public struct frog
{
public frog(int eyes, int legs)
{
this.eyes = eyes;
this.legs = legs;
}
public readonly int legs;
public readonly int eyes;
}
public foo(int unususedInt)
{
al = new List<frog>();
al.Add(new frog(2, 2));
}
}
Hope that solves your prob. Sorry it took me twice to get the problem.
|
|
|
|
|
Interesting, I'll try this. Thanks for your help.
Man, I have to get a better grip on the difference between the instance data and the... uh, non-instance data. Apparently all of my questions about using a struct come down to this.
|
|
|
|
|
I have a problem while using MDI childs in DOTNET C#. On may MDI Parent when one child is maximized all chileds are maximized. But i want to stop some forms from maximizing.
Can any one help me
|
|
|
|
|
Hi..
I am using ASP.NET 2.0 +C#. In my webpage, I have a listbox. I have declared the listbox as shown below:
<code> <td align="center" valign="middle" style="width: 160px">
<asp:ListBox ID="lstPickAvillQueue" runat="server" Height="120px" Width="144px">
</asp:ListBox></td></code>
I want to provide a horizontal scrollbar so that long names can be easily seen. How to provide the horizontal scrollbar to the listbox?
Thank You
Venkat
|
|
|
|
|
Hi..
I checked the code project articles. One author had suggested to use the <div> tag with Overflow:Auto .
I Have changed the code as below. Is this proper?
<code> <tr>
<td align="center" valign="middle" style="width: 160px">
<div style="Height:100px;Width:200px;Overflow:Auto">
<asp:ListBox ID="lstPickAvillQueue" runat="server" Height="120px" Width="144px">
</asp:ListBox> </div></td>
</tr></code>
Thanks & Regards,
Venkat
|
|
|
|
|
Hi,
I am using GridView of WPF.
I need to show horizontal and vertical grid lines.
Please help
|
|
|
|
|
Could anybody give me some idea on how to provide security in remoting.
Thanks & Regards,
|
|
|
|
|
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
|
|
|
|