|
|
I am trying to get Mono.GetOptions to work in my CSharp application that I am building using VS 2005. The application is failing to compile, complaining that my Options subclass does not contain an data member. However, I have clearly defined this member, and it shows as being part of the class when using the Class Browser interface.
Here is the message - "Error 1 'Mono.GetOptions.Options' does not contain a definition for 'file' "
but file is in the class as "public string file" .
Any ideas on what I can do to fix this issue? I will even take suggestions on using a command line parser that is similar to GetOptions.
John Gooch
|
|
|
|
|
You will need to post more code to get a better answer. But I'm assuming that you need to cast the return value of the Mono.GetOptions to your custom options type. Mono.GetOptions will return an object of type Options. If you have a custom Options class, say MyOptions, then you need to cast it to that type in order to access it's members. Like so:
MyOptions o = (MyOptions)Mono.GetOptions(...);
String s = o.file;
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Here is the where I define the class:
<br />
public class SampleOptions : Options <br />
{<br />
[Option("Write report to FILE", 'f')]<br />
public string file;<br />
<br />
[Option("don't print status messages to stdout", 'q')]<br />
public bool quiet;<br />
<br />
[Option("Sample int option", "use-int")]<br />
public int use_int;<br />
<br />
public SampleOptions()<br />
{<br />
base.ParsingMode = OptionsParsingMode.Both;<br />
}<br />
}<br />
<br />
And then I create and use it as per the example I linked to above(It errors on the Console.writeline line) :
<br />
static void Main(string[] args)<br />
{<br />
Options myoptions = new SampleOptions();<br />
myoptions.ProcessArgs(args);<br />
<br />
Console.WriteLine("File name is {0}.", myoptions.file);<br />
<br />
}<br />
<br />
<br />
<br />
John Gooch
|
|
|
|
|
Your problem is with the following line and is what I suspected:
Options myoptions = new SampleOptions();
The myoptions variable is of type Options, not SampleOptions. Eventhough, the actual instance is a SampleOptions, since the variables type is Options it cannot see the file field (which is defined in SampleOptions).
If you update your code to be:
SampleOptions myoptions = new SampleOptions();
Then myoptions will be of type SampleOptions and will be able to see any fields defined in it.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi,
My project windows application.I createn report with Crytal Report in VS.2005.NET.
My creating report code :
CrystalReport_myreport Report= new CrystalReport_myreport();
Report.SetDataSource(MyDataTable);
crystalReportViewer1.ReportSource = Report;
This report work server but client computers give error: LOAD REPORT FAILED
Why client computers give error???
Thanks
|
|
|
|
|
Hi
I have a problem to resize a page in asp.net.
I have a button in page "A.aspx" .When i click the button i want to open a child page.
The size of the child page would be specified by me.How can i do this.Please suggest me.
Arnab
|
|
|
|
|
Sorry To Say It
But U are Not At The right Forum
Try the ASP.NET Forum
Have Fun
Never forget it
|
|
|
|
|
|
Does C# have any similar data view such as the one in utorrent where each item is in different row with its column data?
I want to make a list of items stored in an Access database to display
|
|
|
|
|
Try Using The ListView
It Looks A lot like What you're Asking
P.S
What About DataGridView???
Have U tried It?
Have Fun
Never forget it
|
|
|
|
|
thanks, i havent checked the datagridview. i might do that later
another question regarding the tables
i choose the View to details and set some test rows. when i run the program and click on each row, the entire row wont get selected. if i click on the first column only that row and column will get selected. is there a way to get the entire row selected?
its not an important thing. but i think its neater than the current one
|
|
|
|
|
Depenteds Where ( What kind of control are u using? )
//I have not worked with DataGrid,
//But i think i a bit simliar to DataGridView
In DataGridView it Works fine
Have Fun
Never forget it
|
|
|
|
|
Hi
I have a datagridview in that i have a comboboxColumn
Now i want to set the default value for that so that each newly added row have that default value of the combobox
It means that if the ComboBox values are DR. & Cr.
Then Dr. is default value for that combo in the datagridview column when a new row is added.
Thanks a lot in advance
Katinka
|
|
|
|
|
Try this :
DataGridViewCellStyle.NullValue = "Dr";
U can Do that Visually
Or by writin your'e self The Code
Have Fun
Never forget it
|
|
|
|
|
HY!!!
Thanks a lot!
Have a nice day!
|
|
|
|
|
Dear Gentlemen,
I am stuck with a problem of picturebox. I am working on a map related application in C#. what i deed was, i put the map in the picture box .An object moving in real time, is tracking in the map using longitude and latitude from GPS reciever.
But what i need is to slide the map in the picturebox smoothly if the longitude and latitude is out of the map's longitude and latidue defined in the picturebox?
I would be greatful if any body help me in this matter.
Padam Raj Gurung
|
|
|
|
|
Hi,
forget the PictureBox; replace it by a regular Panel plus some code:
- some initialization to load the picture
- a Paint handler to paint the relevant part of the Image in the Panel, using one
of the many overloads of Graphics.DrawImage().
By adjusting the source rectangle (one of the parameters in DrawImage) you can get any
pan&zoom you want; to update the display, you should adjust the parameters and call
Panel.Invalidate().
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi,
i like to know how to make a Uniqe Color ,like mixed Colores
or maybe Stripes on my UserControl BackColor
Any Idea???
-- modified at 8:51 Tuesday 6th November, 2007
Have Fun
Never forget it
|
|
|
|
|
half-life wrote: how to make a Unique Color
hum? i suggest that it is better if you explain more details about what you wanna do... I'm not so sure what you meant by "how to make a unique color"? let's say "White".. Is it not unique??
|
|
|
|
|
Like :
Blue & Red Stripes O.K
i've UnderStand that i've got to voerride the onPaint...
Can't i Import A Color????
Have Fun
Never forget it
|
|
|
|
|
You will have to develop your own property to set the effects that you would like. Then you will need to override the OnPaintBackground method.
<br />
protected override void OnPaintBackground(PaintEventArgs e)<br />
{<br />
}<br />
|
|
|
|
|
got U
THANKS
P.S
Can't i Import A Color????
Have Fun
Never forget it
|
|
|
|
|
Import a colour?
I'm not sure what you mean, but there's a couple of ways you can get a colour:
1: By Name
Color myColour = Color.DarkGreen;
2: Specify the RGB values
Color myColour = Color.FromRGB(50, 255, 200);
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|