Working with long strings and found this problem. Any advice?
I have an instance where a string builder's Capacity is 1024 and Length is 992.
I am .Append() a string that has a .Length property of 1024.
After .Append() is called, the .ToString() method returns a long "\0\0\0" string.
What is going on? 0.o
If I create a new StringBu...
In C# PInvoke, how do I pass a string buffer so that the C DLL fills it and returns? What will be the PInvoke declaration?
The C function declaration is
int GetData(char* data, int buflength);
In C#, I have declared it as
[DllImport(DllName)]
static extern Int32 GetData([MarshalAs(UnmanagedType.LPStr)]StringBuilder receiveddata, In...
Hi, As I know if i declared a dictionary, i could call myDict.Clear() for reusing purpose.
Now if I declared a sb as a StingBuilder obj.
StringBuilder sb = new StringBuilder();
How to reuse sb? thank you.
Acturally i need print all the possible conditions for mainDict.
one of sb expression like this(inclued in the code below)
sb.A...
string to build up using keyvaluepair is like this: "name1=v1&name2=v2&name3=v3"
what i am doing:
var sb = new StringBuilder();
foreach (var name in nameValues)
{
sb.AppendFormat("{0}={1}&", name.Key, name.Value);
}
//remove last '&' sign, this is what i think is ugly
sb.ToString().Remove(lastIndex);
any elegant way t...
Hi
How can I force a shrink of a DataTable and/or List so that I can free memory efficiently? I am currently removing the processed row from the DataSet every iteration of the loop, but I'm not sure if the memory is being released.
for (int i = m_TotalNumberOfLocalRows - 1; i >= 0; i--)
{
dr = dt.Rows[i];
// Do stuff
dt.Rows.R...
I'm having trouble getting a string back from some c code I wrote.
First some generally unrealated background info: I'd like to receive the user readable string for a TAPI TSP from the TAPI API. I've implemented a semi workable TAPI solution relying on matching driver names to stored strings, but would like to change this to work on per...
i see a few code project solutions:
but wanted to see if there was a regular implementation in javascript?
...
Hi all,
I'm having an issue creating a link like "<a href="javascript:window.open('www.microsoft.com');">Visit Microsoft</a> using stringbuilder. I am adding html to a panel dynamically and I am trying to create a popup link.
The problem is that for some reason the link gets "mixed up". For example:
Dim s As String
sb.Append("<A HREF...
I have a big CLOB (more than 32kB) that I want to read to a String, using StringBuilder. How do I do this in the most efficient way? I can not use the "int length" constructor for StringBuilder since the lenght of my CLOB is longer than a "int" and needs a "long" value.
I am not that confortable with the Java I/O classes, and would like...
I'm looping through a ResultSet in Java; which for testing purposes is returning about 30 rows with 17 Columns (all String data) per row. I'm manually building an XML String out of the results using StringBuilder and its literally taking about 36 seconds for the loop to finish these iterations.
Note: I realize this isn't the best way to...
What is the best method of writing a StringBuilder to a System.IO.Stream?
I am currently doing:
StringBuilder message = new StringBuilder("All your base");
message.Append(" are belong to us");
System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.Text.ASCIIEncoding encoding = new ASCIIEncoding();
stream.Write(encoder.Ge...
Hi there.
I know the subject might be a little strange, but I wasn't sure how to exactly describe my goal
I'm trying to do some Role based permissions in a content management system. The best way I can think of to do this is to pull the list of roles from the database and place them in a CheckBoxList. From there, I save a comma separ...
I'm wondering if this code ...
StringBuilder sb = new StringBuilder("Please read the following messages.");
... initializes sb with a buffer exactly as large as the string passed to the constructor. On the one hand, this would seem the most logical thing. On the other hand, it seems to kind of defeat the purpose of the StringBuilder c...
When I don't include the commented line, prevLineBuffer contains "null." When i do include the commented line it still works, but prints an empty string. Does Java statically allocate space for the declared string and then dynamically allocate space for an additional string in the commented line? Both appear to work...
public class Inde...
How can I send a string to an email with new lines (carriage returns) included?
The problem is that I am sending the string to an email, and the email strips out the carriage returns.
Dim myApp As New Process
emailStringBuilder.Append("mailto:")
emailStringBuilder.Append("&subject=" & tmpID & " - " & subject)
emailString...
Hi,
I need to append an Sqlquery for each row in a datatable.I have 36 columns and based on the datatype of each column i need to append sqlquery.Can anyone suggest me the effective way to do it.Is it bad way of coding to use " + " operator to append text in between the append ?
Following is my code.
query ="INSERT INTO MASTERPI (tag...
I am trying to execute this code in C#.NET to turn an SQL table into a string with proper JSON;
json.AppendFormat("Places: [{{\"AvgDate\": \"{0}\"},\"MarkerID\": \"{1}\"}]", reader["AvgDate"], reader["MarkerID"]);
However it won't let me use the comma separation between the {0} and {1} indexes. The following works fine;
json.AppendFo...
Please, help me understand, what's wrong with this code. (I am trying to build a string, taking parts of it line by line from a text file).
I get a runtime error "In the instance of the object reference not set to an object" on the line strbuild.Append(str);
StreamReader reader = new StreamReader("buf.txt", System.Text.Encodin...
I've got a chunk of text in a StringBuilder object. I need to replace one substring with another. The StringBuilder Replace method can do this, but it replaces every instance of the substring and I only want to replace the first found instance. Is there a way to tell StringBuilder to only do one replace?
I'm sure I could code this up my...
Hello
I have a text template with placehoders that I parse in order to replace placeholders
with real values.
Text Template:
Name:%name%
Age:%age%
I use StringBuilder.Replace() to replace placeholders
sb.Replace("%name%", Person.Name);
Now I want to make more advanced algorithm. Some lines of code are conditional. They
have to b...