Click here to Skip to main content
15,918,967 members
Home / Discussions / C#
   

C#

 
GeneralRe: How Do I Prohibit Users From Sorting In A DataGridView Pin
Joe Marchionna9-Jan-08 8:42
Joe Marchionna9-Jan-08 8:42 
QuestionHow to delete a row from a dataGrid Pin
Imran Adam9-Jan-08 5:22
Imran Adam9-Jan-08 5:22 
GeneralSerializing ints, enums in hexidecimal Pin
Skippums9-Jan-08 4:50
Skippums9-Jan-08 4:50 
GeneralRe: Serializing ints, enums in hexidecimal Pin
Le centriste9-Jan-08 5:21
Le centriste9-Jan-08 5:21 
GeneralRe: Serializing ints, enums in hexidecimal Pin
Skippums9-Jan-08 8:10
Skippums9-Jan-08 8:10 
GeneralRe: Serializing ints, enums in hexidecimal Pin
Le centriste9-Jan-08 8:24
Le centriste9-Jan-08 8:24 
GeneralRe: Serializing ints, enums in hexidecimal Pin
Skippums9-Jan-08 9:27
Skippums9-Jan-08 9:27 
GeneralRe: Serializing ints, enums in hexidecimal Pin
Le centriste9-Jan-08 9:37
Le centriste9-Jan-08 9:37 
Ok, I understand. ISerializable is for binary serialization.

For XML, what you could do is implement properties and decorate them with the attributes of the System.Xml.Serialization namespace. For instance, suppose you want to serialize an enum into an hexadecimal string:

<code>
public class MyClass
{
    public enum SomeEnum
    {
        EnumValue1 = 1,
        EnumValue2 = 2
    }

    private SomeEnum _myEnum = SomeEnum.EnumValue1; // Default

    // Serializable property
    [XmlElement(ElementName="MyEnum")]
    public string MyEnumAsHexString
    {
        get
        {
            return String.Format("{0:X}", (int)this._myEnum);
        }

        set
        {
            // No error handling for clarity.
            int enumValue = Int32.Parse(value, NumberStyles.AllowHexSpecifier);
            this._myEnum = (SomeEnum)enumValue;
        }
    }

    // This property is ignored by XML serialization, only
    // by class clients.
    [XmlIgnore]
    public SomeEnum MyEnum
    {
        get
        {
            return this._myEnum;
        }

        set
        {
            this._myEnum = value;
        }
    }
}
</code>


So, in the example above, your web service will serialize only the hexadecimal string property because the other one is tagged with [XmlIgnore].

-----

You seem eager to impose your preference of preventing others from imposing their preferences on others. -- Red Stateler, Master of Circular Reasoning and other fallacies

If atheism is a religion, then not collecting stamps is a hobby. -- Unknown

God is the only being who, to rule, does not need to exist. -- Charles Baudelaire

GeneralRe: Serializing ints, enums in hexidecimal Pin
Skippums9-Jan-08 10:17
Skippums9-Jan-08 10:17 
GeneralTo add to my other answer... Pin
Le centriste9-Jan-08 9:40
Le centriste9-Jan-08 9:40 
QuestionHow to invoke SQL Function through SqlCommand class Pin
El'Cachubrey9-Jan-08 4:06
El'Cachubrey9-Jan-08 4:06 
AnswerRe: How to invoke SQL Function through SqlCommand class Pin
led mike9-Jan-08 4:31
led mike9-Jan-08 4:31 
AnswerRe: How to invoke SQL Function through SqlCommand class Pin
andyharman9-Jan-08 4:44
professionalandyharman9-Jan-08 4:44 
QuestionHow to catch the event of thowing an exception in Visual Studio Pin
manustone9-Jan-08 3:51
manustone9-Jan-08 3:51 
Generalset child form height Pin
arkiboys9-Jan-08 2:29
arkiboys9-Jan-08 2:29 
GeneralRe: set child form height Pin
Stu Richardson9-Jan-08 2:40
Stu Richardson9-Jan-08 2:40 
GeneralRe: set child form height Pin
arkiboys9-Jan-08 2:49
arkiboys9-Jan-08 2:49 
GeneralRe: set child form height Pin
DaveyM699-Jan-08 3:08
professionalDaveyM699-Jan-08 3:08 
GeneralRe: set child form height Pin
arkiboys9-Jan-08 3:13
arkiboys9-Jan-08 3:13 
GeneralRe: set child form height Pin
DaveyM699-Jan-08 3:24
professionalDaveyM699-Jan-08 3:24 
GeneralRe: set child form height Pin
Stu Richardson9-Jan-08 3:27
Stu Richardson9-Jan-08 3:27 
GeneralRe: set child form height Pin
arkiboys9-Jan-08 3:27
arkiboys9-Jan-08 3:27 
GeneralRe: set child form height Pin
Dave Kreskowiak9-Jan-08 4:59
mveDave Kreskowiak9-Jan-08 4:59 
GeneralRe: set child form height Pin
DaveyM6910-Jan-08 1:12
professionalDaveyM6910-Jan-08 1:12 
GeneralGet GUID of Network Card Pin
Kamal.Afridi9-Jan-08 1:48
Kamal.Afridi9-Jan-08 1:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.