string

C# Object Binary Serialization

I want to make a binary serialize of an object and the result to save it in a database. Person person = new Person(); person.Name = "something"; MemoryStream memorystream = new MemoryStream(); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(memorystream, person); How can I transform memorystream in a string type to be saved ...

Remove one char from a string

Hi Alls, I'd like to remove one char from a string like this: string = "ASDFVGHFJHRSFDZFDJKUYTRDSEADFDHDS" print len(string) (33) So i would like to remove one random char in this string, and then have a len = 32 What's the best way to do so ? EDIT: thanks for your answers, but i forgot something: i'd like to print the char remove...

Get the string representation of a DOM node

Javascript: I have the DOM representation of a node (element or document) and I'm looking for the string representation of it. E.g., var el = document.createElement("<p>"); el.appendChild(document.createTextNode("Test"); should yield: get_string(el) == "<p>Test</p>"; I have the strong feeling, that I'm missing something trivially s...

How To Use \n In a TextBox

I'm developing a program that I'm using a string(generatedCode) that contains some \n to enter a new-line at the textBox that I'm using it(textBox1.Text = generatedCode), but when I'm running the program, instead of breaking that line I'm seeing a square. Remember that I've set the Multiline value of the textBox to True. ...

Python equivalent of ruby's StringScanner?

Is there a python class equivalent to ruby's StringScanner class? I Could hack something together, but i don't want to reinvent the wheel if this already exists. ...

string program for ice cream shop (Edited again)

With the assistance of others, I have redone the code from scratch due to them pointing out numerous errors and things that wouldn't work. Thus I have changed the code massively. I have the program working other than two formatting settings that I can't figure out how to get to work. I need to only print "DAILY SCOOP REPORT" once at ...

C# testing to see if a string is an integer?

Hi, I'm just curios as to whether there is something built into either the c# language or the .net framework that tests to see if something is an integer if (x is an int) // Do something It seems to me that there might be, but I am only a first-year programming student, so I don't know. ...

How to get the first N words from a NSString in Objective-C?

What's the simplest way, given a string: NSString *str = @"Some really really long string is here and I just want the first 10 words, for example"; to result in an NSString with the first N (e.g., 10) words? EDIT: I'd also like to make sure it doesn't fail if the str is shorter than N. ...

Compare Strings in C#

Ok,I am trying to compare two strings every 15 seconds and then update an info box. Here is the code I have so far to get a text document from the web and store it into a string: public String GetData(String url) { WebRequest request = WebRequest.Create(url); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); ...

Using string.Substring() as part of a chain

Hi guys I'm trying to maniplulate a string without making a big issue out of it and spreading it out onto multiple lines, so I'm using some chaining to achieve this. The question I have is, how do I use string.Substring() to drop the last character off my string in this context? In PHP I can pass a negative number as an argument (i.e. ...

Why are the commas in my array reading as a string?

This is what I am trying to do: 1 - I have an array with a string. $photographer_array = "'Alberto Korda', 'Annie Leibowitz', 'Ansel Adams'"; 2 - I am trying to populate an array with that string. array($photographer_array); What it is doing is creating an array with one single entry including all the commas. Why is it reading the...

Removing invalid characters from string in AS3 ready for XML

I need some code for ActionScript 3.0 which will remove any characters which are not valid in an XML attribute. Have spent some time searching google and not found what I'm after. Can anybody help me out? ...

How to check if a position in a string is empty in c#

Hi, I have strings with space seperated values and I would like to pick up from a certain index to another and save it in a variable. The strings are as follows: John Doe Villa Grazia 323334I I managed to store the id card (3rd column) by using: if (line.length > 39) { idCard = line.Substring(39, 46); } Howev...

Splitting a string in C#

I was wondering if somebody could help me use string split to get all occurrences of text in between <p> </p> tags in an HTML document? ...

Java: splitting a comma-separated string but ignoring commas in quotes

I have a string vaguely like this: foo,bar,c;qual="baz,blurb",d;junk="quux,syzygy" that I want to split by commas -- but I need to ignore commas in quotes. How can I do this? Seems like a regexp approach fails; I suppose I can manually scan and enter a different mode when I see a quote, but it would be nice to use preexisting librarie...

LINQ: Entity string field contains any of an array of strings

I want to get a collection of Product entities where the product.Description property contains any of the words in a string array. It would look something like this (result would be any product which had the word "mustard OR "pickles" OR "relish" in the Description text): Dim products As List(Of ProductEntity) = New ProductRepository(...

Connecting to a MySQL database with C# express via ODBC

Hi, I need to connect to a MySQL database via C# express 2008. I think I got the code right apart from the connection string. I obtained this code from a forum but the connection string was for SQLExpress 2005. Can someone please help me on how can I fix this? Here is the code with the SQL Express connection string: //string connection...

Java: PrintStream to String?

I have a function that takes an object of a certain type, and a PrintStream to which to print, and outputs a representation of that object. How can I capture this function's output in a String? Specifically, I want to use it as in a toString method. ...

String encoding of primitive types preserving lexicographic order

Does anyone know of a library for encoding a number of primitive types (like integers, floats, strings, etc) into a string but preserving the lexicographical order of the types? Ideally, I'm looking for a C++ library, but other languages are fine too. Also, one can assume that the format does not need to be encoded in the string itself ...

How to efficiently concatenate strings in Go?

In Go, string is a primitive type, it's readonly, every manipulation to it will create a new string. So, if I want to concatenate strings many times without knowing the length of the resulting string, what's the best way to do it? The naive way would be: s := ""; for i := 0; i < 1000; i++ { s += getShortStringFromSomewhere(); } r...