|
Wouldn't using a char[] be faster than using a StringBuilder?
<br />
char[] c = sr.ReadToEnd().ToCharArray();<br />
<br />
for (int i = 0; i < c.Length; i+=2)<br />
{<br />
c[i] = (char)((int)c[i] - 32);<br />
}<br />
|
|
|
|
|
It would, but you need to enclose the c[i] test with an if (char.IsLetter(c[i])... so that you don't end up converting none alphabetic characters.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello,
I want to copy a string into a byte[] array.
string has a method ToCharArray that returns a char[] but that`s just not good enough, since a char is 2 bytes.
Is there a quick and easy way to accomplish this? In unmanaged C++ I could just do a memcpy or memmove into a designated BYTE array, is there something similar I can use in C#?
Thanks for your feedback,
Davy
|
|
|
|
|
byte[] mybyte = Encoding.ASCII.GetBytes("Hello World");
|
|
|
|
|
byte[] bytes = System.Text.Encoding.ASCII.GetBytes("MyString");
where ASCII can be replaced with other available encodings.
|
|
|
|
|
System.Text.Encoding.
A byte sequence means nothing without the information on how to map the byte sequence to characters. This is what the Encoding classes do.
|
|
|
|
|
Thanks all
That`s what I was looking for!
|
|
|
|
|
hi everyone,
I am working in a C# 2.0 Windows Aplication and it had a menu strip. I made a function to hide some of its MenuItems under certain circumstances. the Function was some thing like this
public static void Hide_MenuItems(MenuStrip menustrip)
{
try{
menustrip.Items["productsMenuStipItem"].Visible = false;
menustrip.Items["productreportsMenuStipItem"].Visible = false;
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
Now that code is giving a Null reference exception on productreportsMenuStipItem which is an item that come under the MenuItem like this Products--->Product Reports.
So far I'm not able to understand why this is happening coz when I write this
productreportsMenuStipItem.Visible = false;
in the form that has that menuStrip it working perfectly alright but when I try to do that in this function it gives out a nullReferenceException. It seems as if the only Menuitems tranfered are the ones that are at level zero. like that productsMenuStripItem.
Can u plz give me a clue so that I can hide the menuStipItems with the help of this function? or atleast explain why this is happening?
thanks in advance
Rocky
|
|
|
|
|
I am guessing this has to do with nested menu items. It seems like you are hiding the parent item so the children items aren't there. I am not sure why you are doing it this way. You can access the object directly.
this:
productreportsMenuStipItem.Visible = false;
is not the same as this:
menustrip.Items["productreportsMenuStipItem"].Visible = false;
One you are marking the menu item itself as not visible. Then other you are using the Menustrip to access the menuitem. I would suggest always accessing the menustripitem directly and I think you won't have any problems.
Hope that helps.
Ben
|
|
|
|
|
Hello,
I have a long treeView, how can I scroll to the top of the control, without selecting anything?
Please help.
|
|
|
|
|
|
well as far as my knowledge goes, I think its impossible really. Think some other way instead of this idea. As far as I see it Crystal reports doesnt allow you to access its inner details via programming.
Rocky
|
|
|
|
|
Hi Everyone,
here i am with really a mystic question.
the scenario is:
-=-=-=-=-=-=-=-=-=-
I have a repeater and a checkbox.The checkbox is databounded in the repeater.There are 4 rows in the database.when the page is loaded,the 4 checkboxes are created dynamically w.r.t rows in table.When the check box is checked,the corresponding id's of the checkboxex are to be captured in an event.
And My query is:
-=-=-=-=-=-=-=-=-=-
how can we get the ID's of the corresponding checkbox when the checkbox is checked?
thanks
tirumal.
-- modified at 6:37 Tuesday 24th April, 2007
|
|
|
|
|
how to create a error log files?
how to handle the user exceptions while run the web application?
|
|
|
|
|
you handle the user exceptions using the traditional try/catch/finally(optional) block.
Keshav Kamat
India
|
|
|
|
|
i actually did not get you properly.
do you mean to say, you want to make sure that the user does not enter wrongly or something.
in that case you want something called validation.
You need to check out key press event in that case.
Keshav Kamat
India
|
|
|
|
|
The error log files can be created in the global.asax page.
the below code might help you.
string errorpath = Server.MapPath(ConfigurationManager.AppSettings.Get("ErrorPath"));
Exception objErr = Server.GetLastError().GetBaseException();
str = str + "Time : " + (DateTime.Now.TimeOfDay).ToString() + "*";
str = str + "Message : " + objErr.Message + "*";
tirumal
|
|
|
|
|
Hi,
I am trying to add to a context menu a textbox suimila to what you have in Access.
is it possible, if so how?
Regards
Alban
|
|
|
|
|
I think its pretty simple just make a new MenuStrip And in the designer view go to the properties of that textbox and add the menu to the contextMenuStrip Property of that text box and thats it.
hope it helps
Rocky
|
|
|
|
|
hi alban,
For .net 1.1
Add a context menu from the toolbox to the form, add sub menu's as required by you
Then go to the textbox property,then set ContextMenu property to context menu which you have created.
For .net 2.0
Add a contextmenustrip from the toolbar to the form, add sub menu's as required by you
Then go to the textbox property, then set ContextMenuStrip property to context menu strip which you have created
|
|
|
|
|
I may have miss explaiend myself.
What i am trying to have is within the context menu having a textbox that would come up as per the menu structure show bellow.
ContextMenu
SubMenuA Textbox
SubMenuB
Thanks
|
|
|
|
|
You can make a borderless form and then use that as your context menu.
Just make the form apear when you right click the textbox.
To exchange information to this context menu, you can add a reference to the base form in the contstructor
of the contectmenuform
Programming code is like magic, just use the right code (magic words) to make happen what you want..
|
|
|
|
|
Hi,
I want to know the difference between array and arrylist.
thanx
|
|
|
|
|
Both are collections.
But you have to provide the size of an array before you use it, may not be compulsory at the time of declaration.
But with an array list, you dont have to.
You use the add property to add on any number of items you want to.
eg ArrayList1.Add("Something"); if it is a string arraylist.
You might want to refer the msdn library for more.
Keshav Kamat
India
|
|
|
|
|