|
Thanks for trying but that doesn't help. www.filehelpers.com
Thanks for trying though.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Kwagga wrote: Any idea how I do that?
I gotta lotsa ideas! No good ones though.
But seriously, I think we need a few more details first. Here are some assumptions I've made, let me know if I'm right or wrong.
engine is of type FileHelper
res is an array or collection of CsvImp objects
CsvImp is a class or struct containing data
What is FileHelper? A third party utility or a class that you or a colleague has written. If it's your own in-house class, you could write an overloaded function of WriteFile() that would accept a
string instead of a CsvImp object. If it's a commercial product, that will make it a little tougher.
BDF
A learned fool is more a fool than an ignorant fool.
-- Moliere
|
|
|
|
|
Big Daddy Farang wrote: engine is of type FileHelper
res is an array or collection of CsvImp objects
CsvImp is a class or struct containing data
All Correct.
Check the Site www.FileHelpers.com[^]
I have posted the question there as well but no help as the creaters of the tool don't seem to be checking the blogg anymore. So, now I'm slightly stuck.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
That's cool, so you probably have the source code available. Writing an overload of WriteFile() may be an option. I say "may be" because depending on what the ultimate disposition of your code is, you might not want to do that due to license issues, etc.
Another option would be to bypass the FileHelper engine and just write the prov string to the .csv file using a StreamWriter or similar. Of course that's quite messy if you're needing to do both at once:
engine.WriteFile("...", res);
// close the file
// re-open the file
streamWriter.WriteLine(prov);
// close the file
// back to top of foreach...
Is it possible to modify CsvImp to contain another field for prov? Then when the res collection gets written, the prov fields are included. Now we're deep into the "any other suggestions" territory.
BDF
A learned fool is more a fool than an ignorant fool.
-- Moliere
|
|
|
|
|
I have decided to just write the prov field out with StreamWriter. I now have two files which I guess I can manualy merge but hey, what else to do.
Thanks for the help and advice mate. I'll wait for the guys at FileHelpers to see if they have a solution to the problem I have at the moment.
Off to now. A bit late this side of the world.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
I think I have found a solution to my problem. I am writing the information in the textbox that I'm using to display the info out to a .txt file and this works 100% now.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Hi I am very new to .NET and C#..
Presently I am reading Jeffrey Richter's "CLR via C#" and here he always mentions (in Type and Member Basics Chapter) that the CLR can call a virtual method non-virtually..
How does CLR do that? What does this mean?
Could anybody explain or give some helpful links??
Thanks!!
|
|
|
|
|
IL has two ways of calling a method. Call and CallVirt. CallVirt basically does some extra checks and stuff to make sure the object the method is being called on is not null, and it also then works out exactly which method to call by looking at the object hierarchy and calling the appropriate virtual method for the actual object passed.
If you write the IL by hand, there is no reason why you couldn't call virtual methods with the Call command, what would be missed out though is the polymorphic part of the call, so exactly the method you specify on the type you specify will be called, rather than the CLR looking at the object hierarchy and finding the appropriate virtual method.
Lets see. Say you had two Classes.
BaseClass and SuperClass (which inherits from BaseClass)
BaseClass defines a method called "TestMethod", SuperClass overrides that method and provides it's own implementation.
In C#, if you create a superclass object, cast it to a BaseClass and then call TestMethod, because it's called with CallVirt, the CLR will locate and call the TestMethod on the SuperClass, and call that, despite the fact that the objects was cast to a BaseClass. This is because even though it's been cast to a BaseClass, the object is still a SuperClass object.
Now, if you edited the IL and changed the CallVirt to a Call command, (your now calling a virtual method non-virtually) that part of the CLR processing wouldn't happen, and it would call the BaseClass method, because that's the Type that has been provided in the call.
If you only ever write in C#, it's nothing really to worry about. C# compiles all instance method calls to a CallVirt command, even if they are not virtual. (they are therefore non-virtual methods being called virtually, which doesn't really matter at all).
This is only ever worth worrying about if you have code that references your code that is not written in C#, it may call your non virtual methods with Call, which is fine to begin with, but it means if you then change your C# non-virtual method to a virtual one, the calling code will be calling a virtual method with the Call command, which as shown above, gives unexpected results.
(Try defining the classes I described, compile it, and use ILDasm to output the IL. You can manually change the callvirt to call and use ILAsm to reassemble the IL. The behaviour of the program changes as I described)
Simon
|
|
|
|
|
Good post Simon. Do you have any good articles where I can learn something about IL ?
|
|
|
|
|
Good idea, maybe I should write up some of the bits about IL I've picked up.
Kenny Kerr has a good intro to MSIL series of artciles[^]
Other than that, I would recommend 'CLR via C#' (Jeffery Richter). Although it doesn't really go into IL that much, he does often describe how the CLR handles things. I picked up this stuff about Call and CallVirt from this book, and then trying things out with ILDasm/ILAsm myself.
Simon
|
|
|
|
|
Indeed a very good post.. You solved all my problems!!
|
|
|
|
|
I don't know how the CLR can choose to call a virtual method non-virtually, but the compiler can do certain optimizations, if it knows that the object on which the method is called is the most derived object. For eg.
interface IA
{
void Method();
}
struct S : IA
{
public void Method() { Console.WriteLine("S"); }
}
S s = new S(); s.Method();
The compiler figures out that S can't be extended any further and therefore compiles s.Method to a call instruction, rather than a callvirt.
|
|
|
|
|
Hi
Is there anyone who can help me? I have to create application that establish VPN Connection.
Thanx in advance.
Regards
Seema
|
|
|
|
|
|
Can anyone give me a code snippet for how to move to the next column of a DataGridView to insert a value. In this case, there is no DB connectivity. I am creating an application that retrieves the property names and values for a control and populates a DataGridView with these values. I can do this:
foreach (PropertyInfo prop in t.GetProperties())
{
dataGridView1.Rows.Add(prop.Name);
dataGridView1.Rows.Add(prop.GetValue(controls[index], null));
}
However, this puts the values in the same column. I have 2 columns in the gridview, and would like the output to appear similar to the properties window in VS. Any help would be greatly appreciated. Thanks!
"If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra
|
|
|
|
|
Create an array (say string[] ) of the data that you want to display. Then add it to the Rows collection of your DataGridView.
Check msdn[^] for the details about DataGridView.
*jaans
|
|
|
|
|
Hi,
Here is the code snippet:
foreach (PropertyInfo info in t.GetProperties())
{
dataGridView1.Rows.Add();
infoName = info.Name;
value = info.MemberType.ToString();
}
private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
dataGridView1.Rows[e.RowIndex].Cells[0].Value = infoName;
dataGridView1.Rows[e.RowIndex].Cells[1].Value = value;
}
Thanks,
Gopal.S
|
|
|
|
|
Thank you kindly.
"If you don't know where you're going, you'll probably end up somewhere else." Yogi Berra
|
|
|
|
|
i want to create new menu type like a icons.
first time i create 2 icons then cliked in first icon, open 2 next icons
so on.
|
|
|
|
|
What you want sounds like a TreeView. Try inheriting from that.
Simon
|
|
|
|
|
no
i want to only icon not a windows or form. like desktop icons
|
|
|
|
|
Sorry then. I don't understand what you're trying to do.
Simon
|
|
|
|
|
i need to know how to get data from the DB and draw the graph in the application window directly.is there any tool i can use?
|
|
|
|
|
Use ADO.NET or Linq to get the data from the database.
If you're using winforms, override the OnPaint method in the form class, and draw onto the graphics object that is on the EventArgs parameter.
If you're using WPF, you can create a Canvas, and add UI elements too it like lines and rectangles by adding them to the Children on the canvas.
If you try to do this and have problems, come back with more specific questions.
Simon
|
|
|
|
|
If you don't want to spend time on creating graphics, then I suggest use Excel Object Library. You can find more on how to use excel with C# here.[^]
There's also an artical that shows how to create chart using Excel Object Library, but it's in J# but I think you should be able to do the same thing in C# with minor changes in your code. http://www.codeproject.com/KB/office/JExcel.aspx[^]
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|