The Coding Lounge

// Please use generics, and C#
Object<LivingInComfort.Couch> myCouch = new Object<LivingInComfort.Couch>();
myCouch.Items.Add(new LivingInComfort.Couch(Blue));

**EDITOR'S NOTE: This program was written in VB for reasons that escape my mind at this time, but I'm fairly sure that it has something to do with the coffee and last night's 3 hours of sleep
 
// Please use generics, and C#
Object<LivingInComfort.Couch> myCouch = new Object<LivingInComfort.Couch>();
myCouch.Items.Add(new LivingInComfort.Couch(Blue));

// Please use the System.Drawing.Color library, in C#

Object<LivingInComfort.Couch> myCouch = new Object<LivingInComfort.Couch>();
myCouch.Items.Add(new LivingInComfort.Couch(System.Drawing.Color.Blue));
 
// Please use the System.Drawing.Color library, in C#

Object<LivingInComfort.Couch> myCouch = new Object<LivingInComfort.Couch>();
myCouch.Items.Add(new LivingInComfort.Couch(System.Drawing.Color.Blue));

// Client is requesting colours that aren't default in System.Drawing.Color, what happened to enum?
Code:
public enum Colors : int
{
    [HTMLCode("#123456")]
    CrazyColor = 1,
    etc,
    etc
}

public class HTMLCode : Attribute
{
    public string HTML
    {  
        get{ return this._HTML;}
        set {this._HTML = value;}
    }
   
    public HTMLCode(string HTML)
    {
        this._HTML = HTML;
    }
}

public class Couch : Furniture
{
    private Colors _CouchColor;
    System.Drawing.Color CouchColor
    { 
        get
        {
            FieldInfo fieldInfo = this._CouchColor.GetType().GetField(this._CouchColor.ToString());

            object[] attribArray = fieldInfo.GetCustomAttributes(false);
            if (attribArray.Length == 0)
                return null;
            else
            {
                HTMLCode code = attribArray[0] as HTMLCode;
                return System.Drawing.ColorTranslator.FromHtml(code.HTML);
            }
        }
    }

    public Couch (Colors  CouchColor)
    {
        this._CouchColor = CouchColor;
    }
}
 
Last edited:
Code:
public enum Colors : int
{
    [HTMLCode("#123456")]
    CrazyColor = 1,
    etc,
    etc
}

public class HTMLCode : Attribute
{
    public string HTML
    {  
        get{ return this._HTML;}
        set {this._HTML = value;}
    }
   
    public HTMLCode(string HTML)
    {
        this._HTML = HTML;
    }
}

public class Couch : Furniture
{
    private [b][u][color=red]Colours[/color][/b][/u] _CouchColor;
    System.Drawing.Color CouchColor
    { 
        get
        {
            FieldInfo fieldInfo = this._CouchColor.GetType().GetField(this._CouchColor.ToString());

            object[] attribArray = fieldInfo.GetCustomAttributes(false);
            if (attribArray.Length == 0)
                return null;
            else
            {
                HTMLCode code = attribArray[0] as HTMLCode;
                return System.Drawing.ColorTranslator.FromHtml(code.HTML);
            }
        }
    }

    public Couch (Colors  CouchColor)
    {
        this._CouchColor = CouchColor;
    }
}

Error 1 The type or namespace name 'Colours' could not be found (are you missing a using directive or an assembly reference?)
 
Error 1 The type or namespace name 'Colours' could not be found (are you missing a using directive or an assembly reference?)

<ol>Dam the Americans</ol>
<ol>By your attempt to mock my typo's I assume you approve of the solution?</ol>
<ol>Attributes FTW</ol>
 
<ol>Dam the Americans</ol>
<ol>By your attempt to mock my typo's I assume you approve of the solution?</ol>
<ol>Attributes FTW</ol>

Code:
<ol>
    <li>I assume you wanted to use List Items in an Ordered List?</li>
    <li>So the Americans even spell "damn" differently?</li>
    <li>Or do you actually want to dam them up in water behind a huge wall?</li>
    <li>What about your type am I mocking? Can a type even own anything?</li>
</ol>
 
Code:
<ol>
    <li>I assume you wanted to use List Items in an Ordered List?</li>
    <li>So the Americans even spell "damn" differently?</li>
    <li>Or do you actually want to dam them up in water behind a huge wall?</li>
    <li>What about your type am I mocking? Can a type even own anything?</li>
</ol>

/* I think I'll stick to comments as I'm not HTML compliant
* What was that about Goodwin's Law and grammar?
/*
 
/* I think I'll stick to comments as I'm not HTML compliant
* What was that about Goodwin's Law and grammar?
/*

Code:
/// <summary>
/// Represents a law.
/// </summary>
class Law
{
    private string _Name;
    private string _Url;
    private string _Comment;

    public Law(string LawName)
    {
        _Name = LawName;
    }

    /// <summary>
    /// Gets or sets the Name of the Law.
    /// </summary>
    [XmlAttribute]
    public string Name
    {
        get { return _Name; } set { _Name = value; }
    }

    /// <summary>
    /// Gets or sets the URL to a web page describing the Law.
    /// </summary>
    [XmlAttribute]
    public string Url
    {
        get { return _Url; } set { _Url = value; }
    }

    /// <summary>
    /// Gets or sets a Comment made about the Law.
    /// </summary>
    [XmlAttribute]
    public string Comment
    {
        get { return _Comment; } set { _Comment = value; }
    }
}

Code:
Law godwin = new Law("Godwin's Law");
godwin.Url = "http://en.wikipedia.org/wiki/Godwin%27s_law";
godwin.Comment = "Note that there is only one O in Godwin.";

Code:
Member farlig = Site.FindMemberByName("FarligOpptreden");
Member dequadin = Site.FindMemberByName("dequadin");
Message msg = new Message();
msg.Body = "Give up yet?";
msg.Emoticon = ":p";
msg.Sender = farlig;
msg.Receiver = dequadin;
msg.Send();
 
Last edited:
Code:
murphy = new Law("Murphy's Law");
murphy.Url = "http://en.wikipedia.org/wiki/Murphy's_law;
murphy.Comment = "Australia just lost the cricket.";
 
// It's declared globally...






// No...

Code:
Member farlig = Site.FindMemberByName("FarligOpptreden");
Member dequadin = Site.FindMemberByName("dequadin");
Message msg = new Message();
msg.Body = "That's bad coding practice and you know it. Grasping for straws here, are we?";
msg.Emoticon = ":D";
msg.Sender = farlig;
msg.Receiver = dequadin;
msg.Send();
 
Code:
Member farlig = Site.FindMemberByName("FarligOpptreden");

if (farlig != null)
{
    GCHandle handle = new GCHandle();
    try
    {   
        handle = GCHandle.Alloc(farlig , GCHandleType.Pinned);
        IntPtr ptr = handle.AddrOfPinnedObject();
        ptr = IntPtr.Zero;
    }
    catch (AgumentException ex)
    {
        farlig = null;
    }    
    finally
    {
        if (handle.IsAllocated) handle.Free();
        GC.Collect();
    }
}
 
Last edited:
Code:
    public class ThreadExiter
    {
        /// <summary>
        /// Exits with StackOverflowException
        /// </summary>
        /// <value>Doesn't matter</value>
        /// <remarks>
        /// "By Design"
        /// </remarks>    
        public bool Exit
        {
            get
            {
                return this.Exit;
            }
            set
            {
                this.Exit = value;               
            }
        }
    }

    [STAThread]
    static void Main()
    {
        ThreadExiter exit = new ThreadExiter();            
        exit.Exit = true;
    }
 
$myarray = ("First","bit","of","PHP","code");
foreach($myarray as $row) {
echo $row." ";
}

echo "<br />Have a nice day!";
 
$myarray = ("First","bit","of","PHP","code");
foreach($myarray as $row) {
echo $row." ";
}

echo "<br />Have a nice day!";
you have an error in your code (line 1)... and you could also shorten the whole thing by doing the following:

$myarray = array("First","bit","of","PHP","code");
echo implode(' ',$myarray).'<br />Have a nice day!';
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X