A bit about the stuff I've done


Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Thursday, 16 August 2012

Installing MONO on CENTOS

I've spent literally hours tearing my hair out trying to get this sorted so I thought I would share what I have found here:

Most of the search results on google are out of date and/or contain links which no longer work.

I also tried compiling everything from source but ran into trouble here too.

Eventually after much headscratching I found a solution :)

Take a look at this page: http://fedoraproject.org/wiki/EPEL

Ignore that this is a fedora project as it works just fine on centos.

Part way down the page under the "How can I use these extra packages?" heading are a couple of links. Choose the one that is appropriate to your version of centos. e.g. I am using centos 6 so I used the "newest version of 'epel-release' for EL6" link.

Download the rpm file and install it.
You should probably verify the rpm before installing, but I couldn't work out how and I was loosing patience by this point!

rpm -i epel-release-*.noarch.rpm
Now you should be able to search for and install the mono packages (and others) using yum.

e.g.
yum install mono-core mono-data mono-devel mono-extras mono-web mono-winforms monodoc mono-web-devel
N.B. there is no monodevelop included in this lot.
And I can't find anywhere to get it either :(

Thursday, 26 April 2012

Why I hate Imports/using

I'm sure other people must find this annoying, not just me.
And even Microsoft do it on MSDN.

What am I on about?

Posting code that requires importing a namespace - without specifying what namespace(s) need to be imported.

Imagine the following code:

Stream stMyStream = new FileStream("SomeFile.txt", FileMode.Open);

Now I know, and you know, that Stream exists within System.IO
but without a using directive at the top of your file, the compiler doesn't know this and it gives you a whole bunch of red squiggly lines.

In the above case it is obvious which namespace you need, but that isn't always so, and you can be left scratchign your head for ages trying to track down which namespace you are missing.

So please people: when you post code example - either use a fully qualified type name, or specify the appropriate namespaces to be used.
e.g.

System.IO.Stream stMyStream = new System.IO.FileStream("SomeFile.txt", System.IO.FileMode.Open);

Just a note to anyone who doesn't know:
the C# directive
using System.IO;
is equivalant to the VB statement
Imports System.IO


To add further confusion both VB and C# have a using statement with is to do with scoping and disposing of variables.


I use both C# and VB so I tend to interchange terms quite a lot!


</Rant>

Thursday, 19 January 2012

Binding a datagridview to a list

Ok, so binding a grid to a list is easy, but what if you want changes in the list to be shown in the grid?
Well actually, it turns out, this is easy too - just not obvious.

Instead of using System.Collections.Generic.List<T>
use System.ComponentModel.BindingList<T>
It's exactly the same in all important regards, but it has the methods necessary for the grid to know that the list has changed

Easy huh!