|
I have a class declared as below.
<br />
class Error_codes<br />
{<br />
public string[] Error_category;<br />
public int[] Error_value;<br />
public string[] Error_comments;<br />
}<br />
I tried instantiating objects to the class by using the constructor as follows
<br />
Error_codes[] error_details = new Error_codes[70];<br />
<br />
TextReader sr = File.OpenText(ErrorCodes_FILE_NAME);<br />
{<br />
string input=null;<br />
int i = 0;<br />
while ((input=sr.ReadLine())!=null) <br />
{<br />
Regex regEx = new Regex("#(\\w*)");<br />
string[] tokens = regEx.Split(input);<br />
error_details[i]= tokens[2].ToString();<br />
error_details[i] = 20;
error_details[i] = tokens[4].ToString();<br />
i++;<br />
}<br />
sr.Close();<br />
}<br />
But I see an error "Cannot implicitly convert type 'string' to 'LoggingImprovements.Error_codes'". How do we instantiate constructors with errors?
|
|
|
|
|
error_details[i] is an object of type Error_codes
so when you use error_details[i]= tokens[2].ToString(); you are indeed trying to assign a string to and object of type Error_codes, i assume this lives in the LoggingImprovements namespace.
are you trying to do this?
error_details[i].Error_category = tokens[2].ToString();
in which case you would want your error_codes class to look like this:
class Error_codes<br />
{<br />
public string Error_category;<br />
public int Error_value;<br />
public string Error_comments;<br />
}
Hope this helps
|
|
|
|
|
Thanks Russel. I understood my error.
|
|
|
|
|
Hello friends
can anyone let me know how to send email through C#
if possible do let me knowplz
|
|
|
|
|
|
And don't cross post.
led mike
|
|
|
|
|
Hi everyone,
I am hoping to create an application in C# that will display a crystal report using a database that is defined at runtime. I've been doing some searching and I'm not sure if it's even possible. I know what fields I want the report to display, but I want to be able to specify, for example, an excel file and the specific columns to get the data from at runtime. Does anyone have advice for accomplishing this, or maybe other reporting tools that would be better suited?
Thanks
Tammy
|
|
|
|
|
It's possible and a headache...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
|
Ravi Mahavrathayajula wrote: string[0][max] tokens = regEx.Split(input);
The above is wrong, usually you don't know in advance how many items Split will return.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
|
What about:
List<string[]> myList = new List<string[]>();
string [] s;
Regex rgx= new Regex(";");
s = rgx.Split("A;B;C");
myList.Add(s);
s = rgx.Split("D;E;F;G;H");
myList.Add(s);
</string[]></string[]>
?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Omit needless local variables.
myList.Add(rgx.Split("D;E;F;G;H"));
|
|
|
|
|
Maybe (expecially if you don't need debugging), anyway it's a matter of taste.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
What's more annoying than people who delete their posts after they are answered ?
I'm not sure either....
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
There shouldn't be a way to delete a post.
|
|
|
|
|
PIEBALDconsult wrote: There shouldn't be a way to delete a post
I agree. Once there has been a reply, the delete link should just disappear..
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Is there any tool or way to compare performance of two statements.
What I generally do is put it in loop and use Timespan to find out the difference.
Is there any better way of doing it? or are there any standard tools available for this?
Keep DotNetting!!
GeekFromIndia
|
|
|
|
|
Yep, you can use a profiler. I use Ants[^], which works for me (it's not free, but there's a trial available).
Standards are great! Everybody should have one!
|
|
|
|
|
$295
thats a costly affair...i would prefer sticking to my looping way...
but thanks for info...i'll try finding if there are any profilers available for less price..
Keep DotNetting!!
GeekFromIndia
|
|
|
|
|
|
I don't think that's that expensive when compared to the amount of time it saves on debugging performance issues. Anyway: The way things are with the dollar right now that's only 187 euros for me .
Standards are great! Everybody should have one!
|
|
|
|
|
just found out ...our company have licenses for http://memprofiler.com/Default.aspx[^]
but it doesnt provide Line-level timings to find out bottle necks...what I am looking for
Keep DotNetting!!
GeekFromIndia
|
|
|
|
|
Not seen that before. Looks quite nice in principle. Does it work well?
Regards,
Rob Philpott.
|
|
|
|
|
Works very nicely. The only problem with it is that is has trouble monitoring WaitHandle and Thread.Join types of statements: It displays actual time as opposed to CPU time. I've been ensured they'll fix this, and if you know about it, this isn't much of problem anyway.
Standards are great! Everybody should have one!
|
|
|
|