a developer's notes – a semi-technical web development BLOG

May 30, 2015

Static / Sticky Footer

Filed under: CSS / Styling,HTML — Duy Nguyen @ 9:38 am
Tags: , , ,

This is the best solution I found so far.

http://mystrd.at/modern-clean-css-sticky-footer/

The CSS.

html {
    position: relative;
    min-height: 100%;
}
body {
    margin: 0 0 100px; /* bottom = footer height */
}
footer {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 100px;
    width: 100%;
}

Here is how you would use it.

<!DOCTYPE html>
<head>
    <title></title>
</head>
<body>
    <nav></nav>
    <article>Lorem ipsum...</article>
    <footer></footer>
</body>
</html>

January 24, 2012

Why is Main in a console app a Static method and why are its methods Static?

Filed under: C# — Duy Nguyen @ 8:47 am
Tags: , , , , , ,

http://stackoverflow.com/questions/1685692/c-sharp-console-application-static-methods
Here is a great explanation!

Member functions don’t have to be static; but if they are not static, that requires you to instantiate a Program object in order to call a member method.

With static methods:

public class Program
{
    public static void Main()
    {
        System.Console.WriteLine(Program.Foo());
    }

    public static string Foo()
    {
        return "Foo";
    }
}

Without static methods (in other words, requiring you to instantiate Program):

public class Program
{
    public static void Main()
    {
        System.Console.WriteLine(new Program().Foo());
    }

    public string Foo() // notice this is NOT static anymore
    {
        return "Foo";
    }
}

Main must be static because otherwise you’d have to tell the compiler how to instantiate the Program class, which may or may not be a trivial task.

Create a free website or blog at WordPress.com.