Click here to Skip to main content
15,886,258 members
Home / Discussions / C#
   

C#

 
QuestionPersonlisation and Shared View Pin
Adeel Shahid23-Oct-08 3:02
Adeel Shahid23-Oct-08 3:02 
NewsC#/CLR-based Stored Procedures in SQL Server 2005 (in the SQL Forum) Pin
James R. Twine23-Oct-08 2:36
James R. Twine23-Oct-08 2:36 
QuestionHow to get SelectedValue from Text ,,, Combobox ? Pin
kindman_nb23-Oct-08 2:31
kindman_nb23-Oct-08 2:31 
QuestionConvert it to Windows Service Pin
Vimalsoft(Pty) Ltd23-Oct-08 2:21
professionalVimalsoft(Pty) Ltd23-Oct-08 2:21 
AnswerRe: Convert it to Windows Service Pin
Simon P Stevens23-Oct-08 2:39
Simon P Stevens23-Oct-08 2:39 
AnswerRe: Convert it to Windows Service Pin
Mark Salsbery23-Oct-08 4:36
Mark Salsbery23-Oct-08 4:36 
Question"inhereting" a struct? Pin
Vodstok23-Oct-08 2:16
Vodstok23-Oct-08 2:16 
AnswerRe: "inhereting" a struct? [modified] Pin
DaveyM6923-Oct-08 2:22
professionalDaveyM6923-Oct-08 2:22 
I would imagine that creating wrappers around the decimal struct would do the job. I did a similar thing for binary, octal and hexadecimal with an int here[^].

[Edit] I found this interesting so I've tried a little bit of coding - figured I may as well share it with you! Depending on what you're doing with this data, this may help. This (incomplete but working) struct wraps three ints and does some basic stuff. [/Edit]
public struct Imperial
{
    public static readonly Imperial Empty = new Imperial();
    public Imperial(int inches)
    {
        m_Yards = 0; // Set default values
        m_Feet = 0;
        m_Inches = 0;
        if (inches != 0)
        {
            m_Yards = inches / 36;
            int remainder = inches % (m_Yards * 36);
            if (remainder != 0)
            {
                m_Feet = remainder / 12;
                if (m_Feet != 0)
                    m_Inches = remainder % (m_Feet * 12);
                else
                    m_Inches = remainder;
            }
        }
    }
    public Imperial(int yards, int feet, int inches)
    {
        m_Yards = yards;
        m_Feet = feet;
        m_Inches = inches;
    }
    public static implicit operator Imperial(int value)
    {
        return new Imperial(value);
    }
    public static Imperial operator +(Imperial value1, Imperial value2)
    {
        return new Imperial(value1.GetTotalInches() + value2.GetTotalInches());
    }
    private int m_Yards;
    private int m_Feet;
    private int m_Inches;
    public int Yards
    {
        get { return m_Yards; }
    }
    public int Feet
    {
        get { return m_Feet; }
    }
    public int Inches
    {
        get { return m_Inches; }
    }
    public int GetTotalInches()
    {
        return ((m_Yards * 36) + (m_Feet * 12) + m_Inches);
    }
    public static Imperial MillimetersToImperial(int millimeters)
    {
        return new Imperial((int)(millimeters * 0.0393700787));
    }
    public override string ToString()
    {
        return string.Format("{0} yards, {1} feet, {2} inches", m_Yards, m_Feet, m_Inches);
    }
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

GeneralRe: "inhereting" a struct? Pin
Vodstok23-Oct-08 3:29
Vodstok23-Oct-08 3:29 
GeneralRe: "inhereting" a struct? Pin
DaveyM6923-Oct-08 4:04
professionalDaveyM6923-Oct-08 4:04 
AnswerRe: "inhereting" a struct? Pin
Guffa23-Oct-08 2:30
Guffa23-Oct-08 2:30 
AnswerRe: "inhereting" a struct? Pin
#realJSOP23-Oct-08 4:32
mve#realJSOP23-Oct-08 4:32 
GeneralRe: "inhereting" a struct? Pin
Vodstok23-Oct-08 4:43
Vodstok23-Oct-08 4:43 
QuestionRichTextBox RightClick [modified] Pin
V.23-Oct-08 2:10
professionalV.23-Oct-08 2:10 
AnswerRe: RichTextBox RightClick Pin
JoeSharp23-Oct-08 4:22
JoeSharp23-Oct-08 4:22 
QuestionUnbound RadioButtonList Selected Item Problem Pin
amit201123-Oct-08 1:59
amit201123-Oct-08 1:59 
QuestionHelp me in exception handaling Pin
Shantonu23-Oct-08 1:38
Shantonu23-Oct-08 1:38 
QuestionRe: Help me in exception handaling Pin
Eddy Vluggen23-Oct-08 2:02
professionalEddy Vluggen23-Oct-08 2:02 
AnswerRe: Help me in exception handaling Pin
josephbhaskar23-Oct-08 3:39
josephbhaskar23-Oct-08 3:39 
Questionsoundx coding Pin
Preeti197923-Oct-08 1:36
Preeti197923-Oct-08 1:36 
AnswerRe: soundx coding Pin
Eddy Vluggen23-Oct-08 1:42
professionalEddy Vluggen23-Oct-08 1:42 
QuestionWhy if i dont convert a integer to string the output will be coming? Pin
Samiullah23-Oct-08 0:43
Samiullah23-Oct-08 0:43 
AnswerRe: Why if i dont convert a integer to string the output will be coming? Pin
Simon P Stevens23-Oct-08 0:54
Simon P Stevens23-Oct-08 0:54 
GeneralRe: Why if i dont convert a integer to string the output will be coming? Pin
Samiullah23-Oct-08 1:56
Samiullah23-Oct-08 1:56 
GeneralRe: Why if i dont convert a integer to string the output will be coming? Pin
Guffa23-Oct-08 2:33
Guffa23-Oct-08 2:33 

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.