Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello every1!! :D
And ANOTHER C# problem...GOSH!! :|
OK...I got this:public static void AddToItems(string itemName, double itemPrice)
{
EditCart.nameList.Items.Add(itemName);
EditCart.priceList.Items.Add(itemPrice);
}
That doesn't work...it tells me that I need an object reference for nameList and priceList, which both are CheckedListBoxes...
I tried replacing "EditCart" with "this", not putting it at all, making the method nonstatic, and various combinations of those...
Is there a way to make nameList and priceList accessible from other classes?? or making this method work?? how??
Thanx!! ;)El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx

I'll give this a shot, though I've never programmed in C#. But it sounds like you might be trying to reference an object that hasn't been instantiated yet. I.E., just declaring nameList and priceList in your EditCart class is not enough. You probably need to use a new operator, in a constructor or something, like nameList = new CheckedListBoxes. Then it would be an Object, and you can reference it. Like I said this is stab in the dark, but it sounds like c# draws from java in that everything is referenced...

Ooooohhh....ok, I'll try that!! thanx!! ;)
Another thing about C# now...do u know how to compile a C# program from within another C# program?? the program I'm making will generate the C# code, and then compile it...but how do I conmpile?? does it have something to do with the
"System.Runtime.CompilerServices" namespace??
Thanx!! ;)El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx

And for the first thing...I went to my code and it was already new'ed to be a CheckedListBox()... :(
What now?? :P
Thanx!! ;)El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx

And...if I'm not bothering u already, why do I get a Win32Exception on the last statement??:
this.text.Text = "C:\\testfile.txt";
if ((File.Exists(this.text.Text)) && (File.Exists(Application.StartupPath + "\\asciimid.exe")))
{
MessageBox.Show("\"" + Application.StartupPath + "\\asciimid.exe\" \"" + this.text.Text + "\" \"" + Application.StartupPath + "\\midi.mid\"");
asciimidRun.StartInfo.FileName = Application.StartupPath + "\\asciimid.exe";
asciimidRun.StartInfo.Arguments = " \"" + this.text.Text + "\" \"" + Application.StartupPath + "\\midi.mid\"";
asciimidRun.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
asciimidRun.Start();
}I included a MessageBox for you to see that the parameters are all correct...
Thanx!! ;)El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |