<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.dotnetzone.gr:443/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>.NET Framework</title><link>https://www.dotnetzone.gr:443/cs/forums/14/ShowForum.aspx</link><description>Θέματα για threading, remoting, reflection, exception handling, security, regex κλπ.</description><dc:language>el</dc:language><generator>CommunityServer 2.1 SP3 (Build: 20423.1)</generator><item><title>Απ: C# Convert a Struct σε byte[]</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/57918.aspx</link><pubDate>Wed, 31 Mar 2010 20:15:51 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:57918</guid><dc:creator>object+</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/57918.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=14&amp;PostID=57918</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://www.dotnetzone.gr/cs/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;nikos123:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Κάνε Serialization.&lt;br&gt;&lt;br&gt;Πρέπει να είναι Serializable και τα υπο-structures&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Αυτο&amp;nbsp;&lt;img src="http://www.dotnetzone.gr/cs/emoticons/emotion-1.gif" alt="Smile" /&gt; .&lt;/div&gt;&lt;div&gt;(Δες για binaryforrmater)&lt;/div&gt;</description></item><item><title>Απ: C# Convert a Struct σε byte[]</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/57916.aspx</link><pubDate>Wed, 31 Mar 2010 16:49:37 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:57916</guid><dc:creator>nikos123</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/57916.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=14&amp;PostID=57916</wfw:commentRss><description>Κάνε Serialization.&lt;br&gt;&lt;br&gt;Πρέπει να είναι Serializable και τα υπο-structures</description></item><item><title>Απ: C# Convert a Struct σε byte[]</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/57588.aspx</link><pubDate>Wed, 10 Mar 2010 18:16:27 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:57588</guid><dc:creator>stefanidou</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/57588.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=14&amp;PostID=57588</wfw:commentRss><description>&lt;br&gt;Σωστά..&lt;br&gt;&lt;br&gt;Λοιπόν αυτό που θέλω να κάνω είναι αυτο το structure το οποιο περιεχει είπαμε κ άλλα structures να το περάσω σε ένα αρχείο και να το ανεβάσω σε ενα ftp. &lt;br&gt;Αυτο που σκεφτηκα ειναι να το "γραψω" σε ενα byte[] επειτα να γραψω το byte[] σε ενα stream κ ετσι να διμηουργησω το αρχείο που θα στειλω. Εχετε να προτείνετε κάτι καλυτερο?&lt;br&gt;</description></item><item><title>Απ: C# Convert a Struct σε byte[]</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/57575.aspx</link><pubDate>Wed, 10 Mar 2010 00:54:48 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:57575</guid><dc:creator>Panagiotis Kefalidis</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/57575.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=14&amp;PostID=57575</wfw:commentRss><description>&lt;P&gt;Μήπως θα ήταν καλύτερα να περιγράψεις για πιο σενάριο θέλεις να το κάνεις αυτό; Μήπως υπάρχει διαφορετική προσέγγιση στο πρόβλημα.&lt;/P&gt;</description></item><item><title>Απ: C# Convert a Struct σε byte[]</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/57573.aspx</link><pubDate>Wed, 10 Mar 2010 00:53:52 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:57573</guid><dc:creator>Panagiotis Kefalidis</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/57573.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=14&amp;PostID=57573</wfw:commentRss><description>Μπορείς να χρησιμοποιήσεις την &lt;A href="http://msdn.microsoft.com/en-us/library/system.bitconverter.aspx"&gt;BitConverter&lt;/A&gt;&amp;nbsp;αλλά το Implementation της GetBytes για τα types που είναι σύνθετα θα πρέπει να το γράψεις εσύ. Το Marshaling δεν είναι ακριβώς unmanaged κώδικας αλλά θέλει παραπάνω προσοχή με το memory management.</description></item><item><title>Απ: C# Convert a Struct σε byte[]</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/57571.aspx</link><pubDate>Wed, 10 Mar 2010 00:41:00 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:57571</guid><dc:creator>stefanidou</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/57571.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=14&amp;PostID=57571</wfw:commentRss><description>Δυστυχώς δεν χρησιμοποιω μονο primitive types. To συγκεκριμενο structrure που θέλω να μετατρέξω σε byte[] περιέχει κι επιπλέον structures. Είχα δοκιμάσει αυτον τον τρόπο αλλα δυστυχώς δεν κάνει για την περιπτωσή μου.&lt;br&gt;Θα ήθελα αν ήταν δυνατόν να μη χρησιμοποιήσω unmanaged κωδικα. Μήπως υπάρχει κάποιος τροπος?&lt;br&gt;</description></item><item><title>Απ: C# Convert a Struct σε byte[]</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/57570.aspx</link><pubDate>Wed, 10 Mar 2010 00:33:32 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:57570</guid><dc:creator>Panagiotis Kefalidis</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/57570.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=14&amp;PostID=57570</wfw:commentRss><description>&lt;P&gt;Γεια σού,&lt;/P&gt;
&lt;P&gt;Εάν χρησιμοποιείς μόνο primitive types (int, string κλπ) μπορείς να χρησιμοποιήσεις την Marshal class και την method StructToPtr. Έχει πολλά Implementations απο διάφορους, ένα που βρήκα στα γρήγορα:&lt;/P&gt;
&lt;P&gt;
&lt;TABLE style="BORDER-RIGHT:#e5e5e5 1px solid;BORDER-TOP:#e5e5e5 1px solid;BORDER-LEFT:#e5e5e5 1px solid;BORDER-BOTTOM:#e5e5e5 1px solid;BACKGROUND-COLOR:#f2f2f2;" cellSpacing=0 cellPadding=0 width="100%" border=0&gt;

&lt;TR style="VERTICAL-ALIGN:top;LINE-HEIGHT:normal;"&gt;
&lt;TD style="WIDTH:40px;TEXT-ALIGN:right;"&gt;&lt;PRE style="BORDER-RIGHT:#e7e7e7 1px solid;PADDING-RIGHT:2px;PADDING-LEFT:2px;FONT-SIZE:11px;PADDING-BOTTOM:2px;MARGIN:0px;COLOR:gray;PADDING-TOP:2px;FONT-FAMILY:courier new;"&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 &lt;/PRE&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;PRE style="PADDING-RIGHT:2px;PADDING-LEFT:8px;PADDING-BOTTOM:2px;MARGIN:0px;PADDING-TOP:2px;"&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:black;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;static&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;byte&lt;/SPAN&gt; [] StructureToByteArray(&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;object&lt;/SPAN&gt; obj)

{

&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;int&lt;/SPAN&gt; len &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; Marshal.SizeOf(obj);

&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;byte&lt;/SPAN&gt; [] arr &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;new&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;byte&lt;/SPAN&gt;[len];

IntPtr ptr &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; Marshal.AllocHGlobal(len);

Marshal.StructureToPtr(obj, ptr, &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;true&lt;/SPAN&gt;);

Marshal.Copy(ptr, arr, 0, len);

Marshal.FreeHGlobal(ptr);

&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;return&lt;/SPAN&gt; arr;

}

&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;static&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;void&lt;/SPAN&gt; ByteArrayToStructure(&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;byte&lt;/SPAN&gt; [] bytearray, &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;ref&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;object&lt;/SPAN&gt; obj)

{

&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;int&lt;/SPAN&gt; len &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; Marshal.SizeOf(obj);

IntPtr i &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; Marshal.AllocHGlobal(len);

Marshal.Copy(bytearray,0, i,len);

obj &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; Marshal.PtrToStructure(i, obj.GetType());

Marshal.FreeHGlobal(i);

}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/P&gt;</description></item><item><title>C# Convert a Struct σε byte[]</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/57568.aspx</link><pubDate>Tue, 09 Mar 2010 22:51:00 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:57568</guid><dc:creator>stefanidou</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/57568.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=14&amp;PostID=57568</wfw:commentRss><description>&lt;br&gt;Καλησπέρα σας,&lt;br&gt;&lt;br&gt;Θα μπορούσα να είχα κάποια βοήθεια σχετικά με το πως θα κάνω Convert ενα structure σε byte[] σε C# .Net 3.5?&lt;br&gt;Ποιές κλάσεις πρέπει να χρησιμοποιήσω?&lt;br&gt;&lt;br&gt;Ευχαριστώ&lt;br&gt;</description></item></channel></rss>