|
Hi Ravi,
Yes C# has been sent and accepted as a Standard with Microsoft and IBM on the board for the committe. Also to note that JScript is also a full programming language now as well with JScript.Net
-V-
|
|
|
|
|
|
I guess no one can realy decide before he has a compiler at hand.
MS gave those at PDC, so how come they are not giving it away to everyone?
|
|
|
|
|
Depends whether you are asking "Is C# the mythical 'Cool' that we all heard rumours about last year", or "Is C# a good language".
According to the recent poll (http://www.codeproject.com/script/poll/detail.asp?topic=71) most people felt C# was definitely uncool - but it is really hard to judge until you've used the new IDE, written some apps and compared the functionality. Personally I feel it will be kinda nice to drop back to C# to write a COM client, then maybe do a little VB to whip up a neat UI, and then roll up the sleaves to get some hard core C++ going - all working together in the same environment. I think everything simply needs to be put into perspective.
As to whether C# is the Cool project, I was talking to the MS guys and got a definite 'sort of but not quite'. Cool was the name for an entire new technology on which .NET was based. C# is a major part of this, and so in a way C# was part Cool, but Cool was more than C#. At least that was my understanding...
|
|
|
|
|
C# is definitely cool to program in. BTW, you won't need to drop back to VB to do UI. C# (as well as managed C++) gets the same RAD support that VB has in VS.NET. Check out the following code I wrote in about a half hour to display three jpg images. Note, this code probably wouldn't be too hard to duplicate in VB, but try this in VC++ using Win32 API NOTE: the use of XML comments. The compiler supports stripping these out into an XML document like so:
<makefile>
all: MyPhotoAlbum.exe
MyPhotoAlbum.exe: MyPhotoAlbum.cs
csc /debug+ /doc:MyPhotoAlbum.xml /t:winexe \
MyPhotoAlbum.cs /r:system.dll \
/r:system.drawing.dll /r:System.WinForms.dll \
/r:System.Data.dll /r:Microsoft.Win32.Interop.dll
namespace CSharpApp
{
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.WinForms;
using System.Data;
///
/// Class representing my application's main window
///
public class MainWindow : System.WinForms.Form
{
/// Required designer variable
private System.ComponentModel.Container components;
private System.WinForms.Button m_button3;
private System.WinForms.Button m_button2;
private System.WinForms.Button m_button1;
///
/// IVar to hold reference of bitmap to paint
///
private System.Drawing.Bitmap m_bitmap;
private System.Drawing.Bitmap m_bitmap1;
private System.Drawing.Bitmap m_bitmap2;
private System.Drawing.Bitmap m_bitmap3;
private System.Drawing.Point m_orgBitmap;
public MainWindow()
{
//
// Required for Win Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after
// InitializeComponent call
//
try
{
m_bitmap1 = new Bitmap(@"c:\images\A.jpg");
m_bitmap2 = new Bitmap(@"c:\images\B.jpg");
m_bitmap3 = new Bitmap(@"c:\images\C.jpg");
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "Bummer!",
MessageBox.IconHand);
}
m_orgBitmap = new Point(10, 60);
}
///
/// Clean up any resources being used
///
public override void Dispose()
{
base.Dispose();
components.Dispose();
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor
///
private void InitializeComponent()
{
this.components =
new System.ComponentModel.Container();
this.m_button1 = new System.WinForms.Button();
this.m_button2 = new System.WinForms.Button();
this.m_button3 = new System.WinForms.Button();
this.AutoScaleBaseSize =
new System.Drawing.Size(5, 13);
this.Text = "My Photo Album";
this.BackColor = System.Drawing.Color.Blue;
this.ClientSize = new System.Drawing.Size(586, 445);
m_button1.Location = new System.Drawing.Point(8, 8);
m_button1.BackColor =
System.Drawing.SystemColors.ControlLight;
m_button1.Size = new System.Drawing.Size(75, 23);
m_button1.TabIndex = 0;
m_button1.Text = "Bitmap 1";
m_button1.AddOnClick(
new System.EventHandler(ButtonClickHandler));
m_button2.Location =
new System.Drawing.Point(104, 8);
m_button2.BackColor =
System.Drawing.SystemColors.ControlLight;
m_button2.Size = new System.Drawing.Size(75, 23);
m_button2.TabIndex = 1;
m_button2.Text = "Bitmap 2";
m_button2.AddOnClick(
new System.EventHandler(ButtonClickHandler));
m_button3.Location =
new System.Drawing.Point(200, 8);
m_button3.BackColor =
System.Drawing.SystemColors.ControlLight;
m_button3.Size = new System.Drawing.Size(75, 23);
m_button3.TabIndex = 2;
m_button3.Text = "Bitmap 3";
m_button3.AddOnClick(
new System.EventHandler(ButtonClickHandler));
this.Controls.Add(m_button1);
this.Controls.Add(m_button2);
this.Controls.Add(m_button3);
}
protected void ButtonClickHandler(object sender,
System.EventArgs e)
{
// Rectangles to store regions to invalidate
Rectangle rectPrev =
new Rectangle(m_orgBitmap, new Size(0,0));
Rectangle rectCurrent =
new Rectangle(m_orgBitmap, new Size(0,0));
// Grab current bitmap's size
if (m_bitmap != null)
rectPrev.Size = m_bitmap.Size;
// Select appropriate bitmap based on the sender
if (sender == m_button1) {
m_bitmap = m_bitmap1;
}
else if (sender == m_button2) {
m_bitmap = m_bitmap2;
}
else {
m_bitmap = m_bitmap3;
}
// Grab new bitmap's size
if (m_bitmap != null)
rectCurrent.Size = m_bitmap.Size;
// Create region, union of both rectangles
Region region = new Region(rectPrev);
region.Union(rectCurrent);
// Invalidate the combined regions
this.Invalidate(region);
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
// Draw background
g.FillRectangle(new SolidBrush(Color.Blue),
e.ClipRectangle);
//Render bitmap image
if (m_bitmap != null)
g.DrawImage(m_bitmap, m_orgBitmap.X,
m_orgBitmap.Y);
}
// The main entry point for the application.
public static void Main(string[] args)
{
Application.Run(new MainWindow());
}
}
}
|
|
|
|
|
WAH! What happened to my spaces?
|
|
|
|
|
It's good ol' HTML doing its thing...
I think you can avoid it by simply wrapping the code inside PRE tags, like this:
< pre>
// some code
int n = 70;
</pre>
Which will look like this:
int n = 70;
Much better, don't you think? And thanks for the sample code. It's amazing how similar it looks to Java.
Regards,
Alvaro
|
|
|
|
|
Hey Keith,
just a remark on your code:
//--------------------------------------
///
/// Clean up any resources being used
///
public override void Dispose()
{
base.Dispose();
components.Dispose();
}
//--------------------------------------
Isn't C# handling the memory freeing?
|
|
|
|
|
That code was inserted by the VS wizard for a "C# Windows Application". As I understand it, C# suffers the same problem as Java. The destructor or finalize method is not called in a deterministic fashion since Garbage Collection is not deterministic. So the docs recommend adding methods with names like Dispose() or Close() if you are holding onto non-memory resources that should be freed immediately when they are no longer needed as opposed to waiting for the GC to run.
|
|
|
|
|
Been dabbling with C# a bit now; I like the structure of the language....
... but where in the heck am I going to find all the dox for provided namespaces? (Can't find 'em anywhere) ... stuff like you used:
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.WinForms;
using System.Data;
|
|
|
|
|
C# is like Basic, in that, Visual Basic is programming in the Basic language, and Cool is programming in the C# language.
so, Visual Basic is Microsoft's implementation of Basic, and Cool is Microsofts implementation of C#.
(unless things have changed a LOT in the last 6 months)
|
|
|
|