|
You sig silly :P
I added "I dislike the black-and-white voting system on questions/answers. " to mine too...
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
Sorry. I forgot I changed my sig, and I don't read my own sig when I proofread my messages...
Thanks for the support!
BTW: I'm just asking to give back what we had before, that hardly qualifies as a revolution, does it?
|
|
|
|
|
[SpacixOne Goes into hysterical motivational speaking mode]
Did the citizens in Boston sit back and allow the English to force them to drink their nasty over priced tea?
NO! they dressed up as native Americans, to which fooled not even the British, and dumped that team into the harbor!
Did the French sit back and let the Queen tell them to eat cake?
NO! They stood up and said they didn't want to be fat and ugly and killed the Queen and King then hired a short, fat, and ugly evil dictator to take over 90% of Western Europe...
Did the Cubans sit back and wait for Castro to die? (well that's debatable at the moment)
NO! they formed a revolution to take down the commies and were slaughtered and captured in huge numbers! They just wished to make Cuba to be the way it was before the commies took over.
Did the protestors in Tiananmen Square sit back and let the guys in tanks tell them what to do?
NO they stood their ground and were abruptly squashed by those giant tanks.
I tell you sir, that our fight against the oppression by our kind, generous, and caring site builders and administrators by disallowing score votes of 2, 3, and 4 on Questions/Answers is also a Revolution.
In my horrible paraphrased words of Alfred Nobel, "I had not know what I made and seems I just blew it.."
[/SpacixOne Goes into hysterical motivational speaking mode]
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
Spacix One wrote: they stood their ground and were abruptly squashed
So I prefer a slightly more subtle approach. Same goals, different means. We will prevail!
|
|
|
|
|
I join you to cheer, Spacix.
regards,
George
|
|
|
|
|
Thanks Mike!
Great!!!!!!
In GC, if gen2 collection is decided to run, then gen2 collection has to wait for gen1 collection complete, and gen1 has to wait for gen0 collection complete?
regards,
George
|
|
|
|
|
Hello everyone,
How could we see the C# compiler expand our code (I mean at source code level, not using ILDasm to see at IL level or using Diassembly at native assembly code level)?
For example, this is how foreach is expanded in C#.
http://www.csharpfriends.com/Spec/index.aspx?specID=15.8.4.htm
thanks in advance,
George
|
|
|
|
|
One way would be to write simple code, then use Reflector[^] to browse the resultant code.
The using statement is the other one that is just some syntactic sugar, it just builds code you could write just as easily, although I think it's a cool thing to use it.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
Thanks Christian,
I have just tried, but no expansion for the following code, why?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] array = new int[100];
foreach (int p in array)
{
Console.WriteLine (p);
}
}
}
}
regards,
George
|
|
|
|
|
Dunno, but if that doesn't work, then I guess all you can do is look at the MSIL, or trust what the books tell you it expands to.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
Thanks Christian,
Could you do me a favor to see whether reflector works for you?
regards,
George
|
|
|
|
|
I would assume you don't see the full expansion because reflector is clever enough to recognise the IL pattern and display the c# that would have formed this. If you switch reflector to IL mode, you will see the raw IL that the C# compiles to. IIRC the C# compiler generates fields and things in IL with < and > signs in their names, which aren't allowed in c#, so there is no risk of a clash.
For example, try using the automatic properties feature of c# 3.0. If you look at it in reflector, you'll see in the IL it's generated a field called something like <myproperty>k_BackingField. Using the '<' signs mean that there's not a risk of the auto generated backing field clashing with any of your fields. But if you switch reflect to C# mode, it'll give you the original automatic property definition. This is reflector recognising the pattern and reversing it back to the original c',
The way to do it is write the C# for a foreach, and also the c# for a for loop, and then compare the IL generated by each.
Simon
|
|
|
|
|
Thanks Simon,
Do you mean C# will expand at IL level, not source code level?
regards,
George
|
|
|
|
|
Yes, you right the source code, will be compiled to IL, which is expanded out, as IL doesn't have a foreach statement.
what reflector does is convert that IL back to C#, but because reflector is quite clever it recognises the IL that is there performs the same functions as a foreach loop would, so when it converts it back to c#, it includes a foreach loop.
Simon
|
|
|
|
|
Thanks Simon,
Is there any online resource about IL language Spec or step by step learning resource? I feel IL is of much difference compared with native assembly language.
regards,
George
|
|
|
|
|
// Save the stream to disk
System.IO.FileStream newFile = new System.IO.FileStream(Server.MapPath(sSavePath + sFilename), System.IO.FileMode.Create);
newFile.Write(myData, 0, myData.Length);
newFile.Close();
TextWriter tw = new StreamWriter("d://fyp//images//saved images//info.txt");
// write a line of text to the file
tw.WriteLine("txtFName.txt*txtLName*IDTextBox*" + sSavePath + sFilename);
// close the stream
tw.Close();
on the
TextWriter tw = new StreamWriter("d://fyp//images//saved images//info.txt");
how do i specify the directory so that it will save to /images on my project folder? without specifying the exact location?
also on the
tw.WriteLine("txtFName.txt*txtLName*IDTextBox*" + sSavePath + sFilename);
the result on the notepad is that it writes exactly the same text to the notepad... how do i make it so that i'll save whatever I input onto my textboxes?
|
|
|
|
|
Thomas Toh wrote: how do i specify the directory so that it will save to /images on my project folder? without specifying the exact location?
The same as you do for the stream, server.mappath.
Thomas Toh wrote: how do i make it so that i'll save whatever I input onto my textboxes?
By removing the quotes. txtFName.Text + " " + txtLName.Text + " " + IDTextBox.Text
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
thanks.. the second one works..
however.. for the first one... is this the correct code?
TextWriter tw = new StreamWriter("Server.MapPath/images/info.txt");
also.. if i write 2 or more image files... it will overwrite the exisiting one... how do i make it so that it will write onto next line in my textfile
modified on Thursday, May 1, 2008 9:52 AM
|
|
|
|
|
Wow.
OK, what have we learned ? When a string is in quotes, it becomes a literal string, NOT code. Try copying the code you use above, and it will work.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
ok thanks...
also.. if i write 2 or more image files... it will overwrite the exisiting one... how do i make it so that it will write onto next line in my textfile
|
|
|
|
|
Hi guys. I need help please. I have two functions in my form. The one is an import function and the other is a validation function to match a field from the import. Now, I am writing the output of the import to a multiline text box but I have a problem with getting the return value from the matchinh function into the text box. Below the code.
This is the search Function:
private string SearchPcode(string inputStr)
{
string retval = "";
int pcode = 0;
if (!int.TryParse(inputStr, out pcode))
{
retval = "Invalid Integer!";
}
else if ((pcode >= 4731) && (pcode <= 6499))
{
retval = "Eastern Cape";
}
else
{
retval = "Invalid PostCode";
}
return retval;
}
This is the import Function:
private void btnOpenFile_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() != DialogResult.OK)
{
this.Close();
}
else
{
txtboxSelectFile.Text = openFileDialog1.FileName;
}
string filePath;
filePath = txtboxSelectFile.Text;
FileHelperEngine<CsvImp> engine = new FileHelperEngine<CsvImp>();
engine.ErrorManager.ErrorMode = ErrorMode.SaveAndContinue;
CsvImp[] res = engine.ReadFile(filePath);
if (engine.ErrorManager.ErrorCount > 0)
engine.ErrorManager.SaveErrors("Errors.txt");
foreach (CsvImp imp in res)
{
SearchPcode(imp.CallComments);
txtboxDisplay.Text += imp.CompanyCode + "\t" + imp.Caller + "\t" +
imp.Reference + "\t" + imp.Agent + "\t" + imp.CallComments + "\t" + Environment.NewLine;
}
}
I want to display the retval just before the Environment.Newline statement.
Any help please?
Thanks in advance
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
You just need to make sure you store the string that is returned. Currently you have:
SearchPcode(imp.CallComments);<br />
txtboxDisplay.Text += ...
In this case the string is returned, but isn't stored anywhere so it's lost. You need another variable to keep it in.
string searchResult = SearchPcode(imp.CallComments);<br />
txtboxDisplay.Text += imp.CompanyCode + "\t" + imp.Caller + "\t" +<br />
imp.Reference + "\t" + imp.Agent + "\t" + imp.CallComments + "\t" + searchResult + Environment.NewLine;
Or, you could use the method more like a variable and do this:
txtboxDisplay.Text += imp.CompanyCode + "\t" + imp.Caller + "\t" +<br />
imp.Reference + "\t" + imp.Agent + "\t" + imp.CallComments + "\t" + SearchPcode(imp.CallComments) + Environment.NewLine;
In this case the string will be returned, and then stored within txtboxDisplay.Text.
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
Brilliant SK Genius. Guess that is why the name?
It works. Thanks a ton matey.
Now I can peacefully again.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Kwagga wrote: Brilliant SK Genius. Guess that is why the name?
Not really, there are people who are much, much better than me.
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
Mr. T and Chuck Norris for example
|
|
|
|