Last Updated: 4/2002
To compare two object references (as close to pointers as you will get in C#
outside of an unsafe block) use the Object.ReferenceEquals static function: if (Object.ReferenceEquals(obj1, obj2)) .... or cast the objects to object first: if ( ((object) str1) == ((object) str2)) ... Note that ReferenceEquals is implemented on the Object static object and not on the object class itself. Therefore is not available on any base class inheriting from object and therefore, for example, there are no such functions as String.ReferenceEquals(...) etc. |
To convert a enum to a string, just use ToString(). To convert back use Enum.Parse(...). Enum.Parse returns a type of object, so another cast is requried. Enum fred = {Small,Medium,Large}; |
Ether use the Picture control (not recommended) or the .NET Framework ImageAnimator class (simplified example below) System; using System.Drawing; using System.Windows.Forms; namespace WinTest { public class AnimatedGIF : UserControl { private Bitmap bmpGIF; public AnimatedGIF() { // Prevent flicker this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); // This call is required by the Windows.Forms Form Designer. InitializeComponent(); // Load graphic bmpGIF = new Bitmap(@"c:\Project\WinTest\EweBeenFlammed.gif"); // Start playing ImageAnimator.Animate(bmpGIF, new EventHandler(this.OnFrameChange)); } public void OnFrameChange(object oSender, System.EventArgs e) { // Next frame ImageAnimator.UpdateFrames(); // Signal redraw required this.Invalidate(); }
protected
override
void
OnPaint(PaintEventArgs e) { |
Misc. Namespaces |
|
Files can be embedded into the build DLL by changing setting the Build Action for the file to "Embedded Resource". Note that if the file is stored in a sub-directory this becomes a namespace and therefore a "." instead of a "/". For example, to read the embedded file originally stored as "css/HRMSControls.css" we would write the following code:
|
|