I want to replace certain characters in an input string with other characters.
The input text has Microsoft left and right smart quotes which I would like to convert to just a single ".
I was planning on using the Replace operation, but am having trouble forming the text string to be searched for.
I would like to replace the input seq...
I have a string[] containing individual words parsed out of a paragraph of text. I need to display each word in its own cell, and have each cell be assigned a dynamic width based on the word's length. I want to be able to have as many words as possible within the maximum width of each row.
In short, I'm trying to take a given parag...
I'm trying to compare a character array against a string like so:
const char *var1 = " ";
var1 = getenv("myEnvVar");
if(var1 == "dev")
{
// do stuff
}
This if statement never validates as true... when I output var1 it is "dev", I was thinking maybe it has something to do with a null terminated string, but the strlen of "dev" and v...
In my application, these "planners" (essentially, article ideas) follow predetermined templates, written in Markdown, with some specific syntax here:
Please write your answer in the following textbox: [...]
Please write your answer in the following textarea:
...So here, on line, you should write one thing.
...Here, on line 2, you shoul...
How does one effectively dispose a StringBuilder object? If an user generates multiple reports in a single sitting, my app ends up using a huge amount of memory.
I've read in a few sites online that the follow may help:
StringBuilder sb = new StringBuilder(1000000);
// loop goes here adding lots of stuff to sb
exampleObject.Text = sb...
I have a list of numbers that i would like to send out onto a socket connection as binary data.
As an example, i start off with the following list:
data = [2,25,0,0,ALPHA,0,23,18,188]
In the above list, ALPHA can be any value between 1 and 999. Initially, I was converting this into a string using
hexdata = ''.join([chr(item) for i...
Using VB.Net I'd like to be able to replace a range of characters in a string in a single line of code.
i.e. something like
Dim charsToReplace as string = "acegi"
Dim stringToBeReplaced as string = "abcdefghijklmnop"
charsToReplace.ToArray().ForEach(Function (c) stringTobeReplaced = stringTobeReplaced.Replace(c, ""))
however, this ...
Hello,
I'm parsing a large text file using PHP and some lines look like this "äåòñêèå ïåñíè", or "ääò", or like this "åãîð ëåòîâ". Is there any way to check if there are more than three characters like this in string?
Thank you.
...
I looked at tinyurl, tinypic, imgur and youtube! I thought they would use a text safe representation of a index and use it as a primary ID in their DB. However trying to put the keys into Convert.FromBase64String("key") yields no results and throw an exception. So these sites dont use a base64 array. What are they using? What might i wan...
How to get Last Index Of "%" in a string in .NET ?
I tried
string subString = content.Substring(0, startIndex);
int nextOpeningComment = subString.LastIndexOf("%", 0);
This is always giving me -1.
Here subString I'm getting is:
<div id=\"xyz\"> \r\n <img alt=\"\" src=\"App_Themes/Default/Images/abc.jpg\" />\r\n <%--
Any h...
I have an array like this
$sports = array(
'Softball - Counties',
'Softball - Eastern',
'Softball - North Harbour',
'Softball - South',
'Softball - Western'
);
and i would like to find the longest common part of the string
so in this instance, it would be 'Softball - ';
I am thinking that I would follow the this process
$i = 1;
// ...
I'm creating a WPF application (in C#) and I need to be able to draw strings using the C# code, not the XAML. The strings will be changing rapidly, so whatever method I use should be able to reflect that. I like the graphics.drawstring method in windows forms. Is there anything similar I can use in WPF?
Edit: Creating FormattedText see...
I am creating an array of string objects in PowerShell which needs to be passed into an Xceed zip library method which expects a string[], but I get an error everytime. It makes me wonder if the PowerShell array is something other than a .NET array. Here is some code:
$string_list = @()
foreach($f in $file_list)
{
$string_list += $f.Fu...
Hi,
What's the fastest way to turn a string into a byte[] array in C#? I'm sending tonnes of string data through sockets and need to optimize every single operation. Currently I transform the strings in to byte[] arrays before sending using:
private static readonly Encoding encoding = new ASCIIEncoding();
//...
byte[] bytes = encodin...
What is a one-liner code for setting a string in python to the string, 0 if the string is empty?
# line_parts[0] can be empty
# if so, set a to the string, 0
# one-liner solution should be part of the following line of code if possible
a = line_parts[0] ...
...
How do I go about printin a NoneType object in Python?
# score can be a NonType object
logging.info("NEW_SCORE : "+score)
Also why is that sometime I see a comma instead of the + above?
...
I am trying to create an implicit conversion from any type (say, Int) to a String...
An implicit conversion to String means RichString methods (like reverse) are not available.
implicit def intToString(i: Int) = String.valueOf(i)
100.toCharArray // => Array[Char] = Array(1, 0, 0)
100.reverse // => error: value reverse is not a member ...
I want to test whether a certain string is contained in a short list of strings. Currently the code is like this:
if (new List<string> { "A", "B", "C" }.Contains (str)) {
However, this seems bloated. For instance, iirc, in Java I could simply write {"A", "B", "C"}.Contains(str) which would be much preferable to the above.
I'm sure th...
Hello. I have a class MyClass, and I would like to override the method ToString() of instances of List:
class MyClass
{
public string Property1 { get; set; }
public int Property2 { get; set; }
/* ... */
public override string ToString()
{
return Property1.ToString() + "-" + Property2.ToString();
}
}
I w...
Hi
I am trying to convert char *str = "10.20.30.40" ; in to unsigned int . can u pls tell me any method is there or any sample code . pls share me.
...