|
Hello everyone,
I am using the following code to retrieve the string content of XML, my question is why there is many trailing zeros in variable content? How to solve it?
static void Main(string[] args)
{
MemoryStream MemoryStream1 = new MemoryStream();
StreamWriter StreamWriter1 = new StreamWriter(MemoryStream1);
XmlTextWriter XMLWriter1 = new XmlTextWriter(StreamWriter1);
XMLWriter1.WriteStartDocument();
XMLWriter1.WriteStartElement("Entity");
XMLWriter1.WriteAttributeString("node", "Hello Node");
XMLWriter1.WriteEndElement();
XMLWriter1.WriteEndDocument();
XMLWriter1.Flush();
string content = Encoding.UTF8.GetString(MemoryStream1.GetBuffer());
return;
}
thanks in advance,
George
|
|
|
|
|
|
Thanks leppie,
It works!
regards,
George
|
|
|
|
|
Hi! All
I m working on a project who has images, icons defined in Resources Properties. All these loads at run time. but when i remove some images from Resources then it prompts error messages. I want to handle it if the image exist then it appears if it does not exist then does not.
Let me tell how to Handle this
these are accessed as
this.BackGroundImage = MyProject.Properties.Resources.Logo;
it is ok
when i remove "logo" from Resources.
then a compile time error: logo is identified.
* So far i handle this. as i make an empty image with same name i removed.
but that is the not a solution.
Any suggestion regarding this. will be anticipated.
Thanks in advance.
|
|
|
|
|
Instead of linking the file at compile time, you can embed it in the .resx file. There will be a Persistence property for the image when you open the Resources.resx file in IDE.
Also, If you want to remove the image, you can remove it from resources also, why you want to keep it if its not used?
*jaans
|
|
|
|
|
Hi.
im currently stuck in a small problem which i cant seem to overcome
i have built a small easy tracking service which runs with timers and takes the current address from internet explorer bar and writes it on a notepad
im using a refference for .COM internet controls 6 -> shDocVw.ShellWindows
now, when i compile the program-it works perfectly fine (i even tried to build it on a webform it runs smoothly with no problems at all)
But when im trying to run the service after installing it with installutil
i get the error "COM object with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} is either not
valid or not registered"
and it get closed by itself
any magical solutions???
thanks alot!
|
|
|
|
|
When u make a function call, all the value type of the calling function are pushed in stack. As soon as function returns control, the value types & memory used by variables inside function got released.
string and object are refrence type.
class A
{
string abc = "";
...
...
...
}
class B
{
A obj = new A();
obj.abc = "Value";
}
class C
{
A obj = new A();
}
Now sequence in which these class got called is A->B->C.
What happen to value i stored in abc during class B, does It got restore to default by C class obj creation.
What is the scope of variables declare at class level, as soon as control comes out from a class does they restore to default?
Thanks & regards.
|
|
|
|
|
Jon Skeet has an excellent article here[^]. It's worth reading.
|
|
|
|
|
N a v a n e e t h wrote: Jon Skeet has an excellent article here[^]. It's worth reading.
I did read that one. But i couldn't grasp whole.
will u please tell me, with refrence to my original post,
what value does abc hold if i use it after executing C class.
|
|
|
|
|
humdumof wrote: What happen to value i stored in abc during class B, does It got restore to default by C class obj creation.
No, the instance of A that is created in the B class is separate from the instance of A created in the C class.
humdumof wrote: What is the scope of variables declare at class level, as soon as control comes out from a class does they restore to default?
At the class level, you have to distinguish between class members (static variables) and instance members (member variables). A static variable in a class exists only once and exists in the class rather than in an instance of the class. A member variable exists in an instance of the class, so it's separate for each instance. A member variable retains it's value as long as the instance exists.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: A member variable exists in an instance of the class, so it's separate for each instance. A member variable retains it's value as long as the instance exists.
class test
{
string abc = "";
}
class Test2
{
test t1 = new test();
t1.abc = "some value";
test t2 = new test();
t2.abc = "next value";
}
Does it means as long as t1 exist(not garbage collected), t1.abc =="some value" ?
Means t1 is seprate & t2 is seprate copy?
Is it correct?
What i thought, suppose there exist A, B, C classes.
set the class A feild within B, then i was trying to access that value(which i set in B) in C by another obj created inside C.
We cant set like this, can we?
modified on Wednesday, June 11, 2008 5:55 AM
|
|
|
|
|
humdumof wrote: Does it means as long as t1 exist(not garbage collected), t1.abc =="some value" ?
..if you don't change the value
humdumof wrote:
Means t1 is seprate & t2 is seprate copy?
Is it correct?
t1 and t2 are different instance of Type test, yes.
|
|
|
|
|
humdumof wrote: Means t1 is seprate & t2 is seprate copy?
Is it correct?
Yes.
humdumof wrote: What i thought, suppose there exist A, B, C classes.
set the class A feild within B, then i was trying to access that value(which i set in B) in C by another obj created inside C.
We cant set like this, can we?
No, you can't. They are separate instances, and they are not aware of each other.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks a lot for your replies.
|
|
|
|
|
How to reverse the string by the following manner ?
If string is "This is the test".
1] Reverse string should be "tset eht si siht"
2] other one: "siht si eht tset" (for this, using substring function)
|
|
|
|
|
Homework ?
We won't help you; You have to do it yourself. We can help you when you are struck somewhere.
|
|
|
|
|
How abt a loop which iterates the length times of the given string and stores the values from the last char index to first in another string
Try it once if u struck post code
If You win You need not Explain............
But If You Loose You Should not be there to Explain......
|
|
|
|
|
string result = myString == "This is the test"?"tset eht si siht":"siht si eht tset".SubString(0,16);
That should do it, 100% according to your spec
|
|
|
|
|
With some logic thinking you can use the String.ToCharArray(); and the rest I leave up to you...
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
I don't normally help with homework but today I'm feeling generous:
public string ReverseString1(string s)
{
return "tset eht si siht";
}
public string ReverseString2(string s)
{
return "siht si eht tset";
}
|
|
|
|
|
First, we never support code solicitations here. But there is a proven saying that the lotus flower grows only in marshy pond. You seem to prove this saying by initiating a brainstorming topic of 'XOR in C#' through a gibberish post.
Here goes the topic:
http://weblogs.sqlteam.com/mladenp/archive/2006/03/19/9350.aspx[^]
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
All the world's a stage,
And all the men and women merely players.
They have their exits and their entrances;
And one man in his time plays many parts... --William Shakespeare
|
|
|
|
|
|
VS 2005 ? Cristal Report?
Have Fun
Never forget it
|
|
|
|
|
VS2008, MS Reporting services ... but thanks I came right
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
AFAIK you need to select a table. Did you try all the idiot options?
|
|
|
|