Scott Hanselman

More interesting code from my buddy Sairama - How to create an object with a private constructor

August 07, 2003 Comment on this post [3] Posted in Web Services
Sponsored By

using System;
namespace Corillian.Testing
{
 
     class PrivateClass
      {
            public string Name;
            public int    Age;
            private PrivateClass() 
            { 
                  Name = "not initialized";
                  Age = 0;
            }
      } 

      class Test
      {
            static void Main(string[] args)
            {
                  /// The following statement will not work as the constructor is private
                  /// PrivateClass newpTest = new PrivateClass();
                  /// But you can create the object through Serialization 
                  PrivateClass ptest = (PrivateClass)System.Runtime.Serialization.FormatterServices.GetUninitializedObject( typeof(PrivateClass) );
                  ptest.Name = "Scott";
                  ptest.Age = 0x1D;

                  Console.WriteLine( String.Format("{0} {1}",ptest.Name,ptest.Age );
            }
      }
}

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Converting to a DateTime from time_t

August 05, 2003 Comment on this post [0] Posted in
Sponsored By

Oo! Good stuff…I need a copy for myself…

This code just went by an internal alias and I thought I’d record it here.

public static DateTime Time_T2DateTime(uint time_t)
{
    long win32FileTime = 10000000*(long)time_t + 116444736000000000;
    return DateTime.FromFileTimeUtc(win32FileTime);
}

[Brad Abrams]

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

How many ways to Beep and Make Noise in .NET and C#

August 01, 2003 Comment on this post [0] Posted in Web Services | XML
Sponsored By

At the PADNUG meeting last night the question (Lord knows why this always comes up :) on how to make the system "beep" was asked.  Here's two kinds of beeps, and links to some source.

The "PC Beep," including frequency and duration:

using System.Runtime.InteropServices;
class MainClass
{
[DllImport("kernel32.dll")]
public static extern bool Beep(int freq,int duration);

 public
static void Main(string
[] args)
 {
 
Beep(1000,1000);
  Beep(2000,500);
 }
}

The considerably more interesting "MessageBeep" (via BradA) that uses the Wav files that are configured in the Sounds Control Panel.

public enum MessageBeepType
{
    Default = -1,
    Ok = 0x00000000,
    Error = 0x00000010,
    Question = 0x00000020,
    Warning = 0x00000030,
    Information = 0x00000040,
}

[DllImport("user32.dll", SetLastError=true)]
public static extern bool MessageBeep(
    MessageBeepType type
);

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

.DOT COMMON - A Beat Poem by Scott Hanselman

August 01, 2003 Comment on this post [0] Posted in Gaming
Sponsored By

I woke up at 3am last night and wrote this Poem.  I will probably perform it at the LuvJonz at Ohm on Weds the 6th.


.DOT COMMON

We watch UPN's Fake life via a one way transmission
Oh, Those wacky girlfriends
But you are more than my friend, girl
You are my life, my wife, My only source of strife 

man and wife We fight

 But we make up, and that make-up is a wake up
Calling me to appreciate MY fate, MY life, MY wife
But Fake life calls again, this time it's a two way transmission 

UPN makes way for TCP/IP, U see I see the calls of the green screen and the..chat
You've got mail.
Maybe he's got mail, you don't.  Your male, yo' man, is on-line, on yo' time. 

The internet being a means to facilitate data transmission and exchange
At this rate he/I may be your ex ... change
Is not always for the better

slash slash, I want my HTTP-Stolen-time-back

But this Internet, this new network, isn't about you and me,
It's about me and everyone...but you' 

Xbox Live isn't Livin'
But I am Finding my Solace in the Start Menu
I'm aLive in Windows 95
The C drive affects our sex drive
Letters take my attention
Creates dissention increases contention 

Compete, take a back seat, you retreat in defeat
My computer has become my suitor
The internet my friend
We don't conjugate conjugally
We procreate minimally

And you, my mate, translate to a different state, that of
Roommate - correspondingly lightweight

Bringing together of gentle rank and file
attachments in this Global community

I'm closer to my DOT-PenPal's locale
Than friends
Shall Speak now or forever hold their peace
I'd never risk
This marriage
This earnest Endeavour
With who-so-what-ever
Till Death do us part ways
Death - The time when something ends
Our DOT com-mon law marriage

- Scott Hanselman ©2003

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Portland Area .NET Users Group (PADNUG) - The After Party

August 01, 2003 Comment on this post [1] Posted in Musings
Sponsored By

Had a blast at the PADNUG meeting tonight.  The pizza delivery failed so we all went over to the Buffalo Gap, and enjoyed a buffet on the house.  Hung out with Rory Blyth, who is clever in person as well as in the blogosphere.  I mentioned I'd sold three Commodore 64s today (+Drives, Monitors, and a Koala Pad) and we talked about BBSes.  He also was a big BBS'er back in the day and I was completely shocked to hear that he'd heard of my little BBS...I noticed it's listed in the definitive source of BBS info, the PDX BBS List.  Either way, a bloody fine time.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.