|
I was trying to convert a string to a HEX value.... snipplet below will help anyone who was trying to do the same.
private string CovertToHex(string text)
{
string hex = "";
foreach (char c in text)
{
int tmp = c;
hex += String.Format("{0:x2}", (uint)System.Convert.ToUInt32(tmp.ToString()));
}
return hex;
}
|
|
|
|
|
That's not html encoding at all, that's url encoding.
However, the only character that needs encoding in that string would be the space, so you would end up with either "Hello+World" or "Hello%20World".
Fayu wrote: snipplet below will help anyone who was trying to do the same.
Sure, as long as they don't use the code as it is. Using += to create a string scales very badly. The execution time grows very fast when the strings get longer. For every character that you add to the string, the conversion takes roughly twice as long. You should use a StringBuilder to build the string instead.
Also, you are doing a lot of conversions that is totally unneccesary. You are converting the charcter to an int value, which is good, but then you are converting that into a string, only to parse it into an uint value, which you then cast to an uint value before finally formatting into a string again.
private string UrlEncodeAllCharacters(string text) {
StringBuilder builder = new StringBuilder(text.Length * 3);
foreach (char c in text) {
builder.Append('%').Append(((int)c).ToString("x2"));
}
return builder.ToString();
}
Note: The code does not support characters with a character code above 255, for that you need to encode the text into a byte array first.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Thursday, October 23, 2008 4:19 AM
|
|
|
|
|
you are absolutely correct. += not a very good technique.
|
|
|
|
|
hi evrybody
i have an idea i would like to achive it but i dont know what is the technic i should use
i want to make a screen for registring the entrance of cars in parking and i finish developing of read ticket by barcode and capture the car image and evrything is ok with me but the idea is how can i fource user to dont save the data befor the admin set the aprove for saving , so should the admin watch the life change of this screen and aprove the data then the user can save
i mean i want the admin see and control the screen from his machine while the user registar the data from his machine
i hope it can be clear
MD_NADA
|
|
|
|
|
you create Workflow for that.
cheers,
Abhijit
|
|
|
|
|
thanks for your replay
i will send you a workflow but i need to know the technice i should use for this idea
i hope i can get an example for my wish
MD_NADA
|
|
|
|
|
hi
i want hidding data in slack space,in unused space in stream in block in file of microsoft word document 2003 ,
my step is
1- loading the header of doc. file so i finding the Array of BAT which contain the index of unused space like this BAT[1]=-1
this means block 1 is empty
but my problem is how can i access to block 1 in file
am stoping at this point .........
can any bodt help me???????
|
|
|
|
|
Is there a more or less easy way to hide the double-headed rezise arrows on a windows form? I don't want the user to see them because he/she can not resize the form anyway.
|
|
|
|
|
FormBorderStyle?
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Beat me to it by a couple of seconds!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Yeah I noticed ,
but as you can see I was using letters veeery sparingly
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Thank you for answering so fast once again, Mika!
|
|
|
|
|
No problem.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Change the Form's FormBorderStyleProperty to one of the fixed ones.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I am having a string which is a contains the file markers as {/ a , b , c \} i need to display the drop down list dynamically where ever i find the {/ \} and also need to add the values in the drop down list.Can any one help me.
My sample string looks like this
A snail has a soft body that is covered by a hard shell. The body is long and it is {/broom, match, slimy*/}. The shell helps to protect the {/order, snail*, foamy/} and it keeps the body moist. Snail {/shells*, escape, cherry/} can be spiral, pointed, or flat in {/tough, shape*, level/}.
|
|
|
|
|
Dropdownlist can be populated from an array.
If you want to create an array based on a separator, an easy way is to use string.Split -method.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
did u got a solution for this problem
|
|
|
|
|
Hi guys. I need some help on the following pls. the issue is like this:
I put a panel on a form. when the user clicks the panel
a new pictureBox that holds an image is created with a unique name.
Those pictureBoxes are stored in a BindingList declared in code.
How can I make the bindingNavigator shows the number or name of a specific picture when It is clicked so I know for sure i am changing that xyz picture.
|
|
|
|
|
You have already posted this question on this forum less than day ago. Reposting it is considered rude and won't help you to get more answers.
Instead, you perhaps should modify the original question so that it would be easier or more tempting to answer. One way to do this could be posting your current code (or part of it) and clearly pointing out the problem or what you have already tried.
|
|
|
|
|
Hi,
I am trying to get the FieldInfo for my TabControl.
In particular I am interested in EVENT_SELECTEDINDEXCHANGED.
I have method to which I am passing my TabControl object, and it's
a "target" variable.
targetType = target.GetType();
FieldInfo[] fields = targetType.GetFields(BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic);
Now I am trying to see if any of the fields in the fieldinfo array contains EVENT_SELECTEDINDEXCHANGED.
Any help is appreciated.
Thank you
|
|
|
|
|
SelectedIndexChanged is an event, not a field. So if you're trying to get info about it using reflection, use GetEvents -method (or if you already know the event, GetEvent)instead of GetFields .
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
I'm new to C#, and I'm making a Dictionary that is supposed to be able to pronounce coptic language, I have done most of the work, but when I started making it pronounce coptic I found it really difficult. My idea was to take the coptic text and convert it into something like IPA then pass it to speak() method.
It doesn't work.
Would anybody tell me where to start?
|
|
|
|
|
|
User loves to post same question in multiple forums.
Blog link to be reinstated at a later date.
|
|
|
|
|
Give me a break...grow up
|
|
|
|