|
|
I want help in accessing all the UI Elements within a form of a WPF wiindows application. Kindly help.
-----Have A Nice Day-----
|
|
|
|
|
How to assign the values from two dimensional array into list<t>class in c#.net?
|
|
|
|
|
Loads of ways.
1) Do it yourself. Create a new list. Use a foreach loop. Loop through every item in the array and add it to the list.
2) Use .CopyTo to copy it to a single dimensional array, then all .ToList on the single dimensional array.
3) If you using .net 3.5, refernce the System.Linq assembly as use the Cast method:
IEnumerable<string> asList;
asList = myArray.Cast<string>();
</string></string>
This give you an enumerable, which you can easily convert to a list if you want.
The real question is why do you want a 2d array as a list?
If you have data that is in 2 dimensions, why would you want to flatten it to 1 dimension. You can still use Foreach on a 2d array and loop over every element.
Simon
|
|
|
|
|
Hello everyone,
I want to use System.ServiceProcess in a console based application -- other than Windows Service application. But when add statement like -- "using System.ServiceProcess", there is compile error like,
error CS0234: The type or namespace name 'ServiceProcess' does not exist in the namespace 'System' (are you missing an assembly reference?)
Does anyone know the root cause and how to solve it?
thanks in advance,
George
|
|
|
|
|
You need to add a reference to System.ServiceProcess to your project.
|
|
|
|
|
Thanks Bert,
Question answered.
regards,
George
|
|
|
|
|
Hello everyone,
1.
I am wondering what is the relationship between various C# XML types (e.g. XMLWriter, XPath, XMLDocument, XMLSerializer, etc.) and MSXML package? Does all the types just wrap and call the functons in MSXML package?
2.
When install .Net Framework Runtime, MSXML will be installed automatically?
thanks in advance,
George
|
|
|
|
|
George_George wrote: various C# XML types (e.g. XMLWriter, XPath, XMLDocument, XMLSerializer, etc.)
They are .NET framework classes and not C#. I don't know what you are asking. MSXML is a separate SDK which will be useful for JScript users.
2 - I think so.
|
|
|
|
|
Thanks N a v a n e e t h!
You mean MSXML is a separate thing and has nothing with CLR XML related function (no dependencies)?
regards,
George
|
|
|
|
|
Yep, you can use MSXML with C#, but then you have to deal with all of it's problems, which are normally worse than what you are trying to avoid.
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
Thanks Spacix,
I am still a little confused. Does the C# XML classes (in more details CLR) dependent on MSXML? Or they are separate things (products/SDKs)?
regards,
George
|
|
|
|
|
They are 100% separate things, MSXML is legacy XML interface from a while back build into IE5.5 and still used for XML DOM in JScript along with MSHTML.
Most people have used Msxml2 if you've messed with AJAX in IE.
System.XML and MSXML are incompatabale data types. I don't know of, nor heard of a way to Marshal from one to the other.
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
Thanks Spacix,
Question answered.
regards,
George
|
|
|
|
|
I am maintaining some code in C# and I just came across "??" used in code:
string result = (_price ?? 0).ToString("C");
What does "??" mean in C#?
|
|
|
|
|
Check this
http://weblogs.asp.net/mikaelsoderstrom/archive/2008/01/02/tip-of-the-day-double-question-mark.aspx
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
It's a short for
_price == null ? 0 : _price;
|
|
|
|
|
Which is short for
if(_price == null)<br />
return 0;<br />
<br />
return _price;
Which i short for...
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Is this shortcut new since .NET 2.0? I don't remember it in .NET 1.1 - I just used the regular ternary style.
|
|
|
|
|
Hi,
I have this methods and they work fine for FileStreams, but once I try to use the Xml.Save(stream) option and encode this stream, it reads nothing from it. Here is my code:
private void geraGzipToolStripMenuItem1_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<teste><dirso>ama posa</dirso></teste>");
FileStream f = new FileStream("C:\\DADOS\\JR\\JRFW\\bin\\output\\read.xml.gz",
FileMode.OpenOrCreate, FileAccess.Write);
GZipEx gz = new GZipEx();
gz.EncodeXml(doc, f);
}
public void EncodeXml(XmlDocument xml, Stream streamOut)
{
Stream m = new MemoryStream();
xml.Save(m);
EncodeStream(m, streamOut);
xml.Save("C:\\DADOS\\JR\\JRFW\\bin\\output\\teste.xml");
}
public void EncodeStream(Stream streamIn, Stream streamOut)
{
GZipOutputStream gz = new GZipOutputStream(streamOut);
byte[] btout = new byte[bufferSize];
int nRead;
while ((nRead = streamIn.Read(btout, 0, bufferSize)) > 0)
{
gz.Write(btout, 0, nRead);
}
gz.Flush();
gz.Close();
streamOut.Close();
}
Please, don't worry about GZipOutputStream. It's working fine. Just the streamIn is not reading anything to btout. I also checked the streamIn length and it DO have data.
Thanks,
Dirso.
|
|
|
|
|
|
You're right
streamIn.Seek(0, SeekOrigin.Begin); Sorry
Thanks,
Dirso
|
|
|
|
|
Hi Friends .
I had some question about base64 string.
First : What's the base64 string ?
Second : How can we find, our string is base64 string ?
Third : How can we create base64 string from an image ?
Fourth : I want to create Image type from base64 string , How I can do it ?
Thanks in advance.
Sorry for my English. I'm a freshman .
|
|
|
|
|
Check out System.Convert.ToBase64String and System.Convert.FromBase64String in the MSDN doc. I've never used it but the methods are in place.
|
|
|
|
|
M-Dayyan wrote: What's the base64 string ?
It is an ASCII representation of binary data. The 64 means that it splits the raw binary up into 6 bit chunks (0-63) and encodes them as letters, numbers and a few symbols 26 (a-z) + 26 (A-Z) + 10 (0-9) + some symbols. More detail can be found here[^]
M-Dayyan wrote: How can we find, our string is base64 string ?
Because it only uses the characters in the standard. If it contains any other characters (excluding whitespace) then it is not base64
M-Dayyan wrote: How can we create base64 string from an image ?
M-Dayyan wrote: Fourth : I want to create Image type from base64 string , How I can do it ?
The answer for both is pretty much the same, but one is the reverse of the other.
There are methods in the .NET framework for this. I think you might want to look at the Convert class (use Google to find it). It has "Base64" in the method name.
The conversion will turn the base64 in to binary (a byte array) which can be used to create an Image object of some description.
|
|
|
|