A small something I threw together to get a feel for the C# class library, keywords, and of course, Visual Studio 2012.
It's a small snippet that converts a string object into 8-bit binary sequences, and 8-bit sequences back into characters. A tag "b" is indicated at the end of a string to denote that the string is in binary form. It's methods are static so they must be called using the class name.
"Binary.ToBinary("Hello"); => 01001000 01100101 01101100 01101100 01101111b"
"Binary.ToBinary("H"); => "H" = 01001000b"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Binary
{
class Program
{
static void Main(string[] args)
{
}
//Converts the supplied string into separate 8-bit binary sequences.
//"H" = 01001000b "Hello" = 01001000 01100101 01101100 01101100 01101111b
//"b" is tagged at the end of each sequence to denote that the string is in binary.
public static string ToBinary(string bin)
{
char[] c = bin.ToCharArray();
string o = "", s = "";
foreach (char ch in c)
{
int tmp = (int)ch;
s = "";
while (tmp > 1)
{
s = Convert.ToString((tmp % 2)) + s;
tmp = (tmp / 2);
}
s = Pad(Convert.ToString(tmp) + s, 8);
o += s + " ";
}
return o + "\bb";
}//END Method ToBinary(string s);
//Converts sequences back to strings
//Sequences tagged with "b" will be treated as binary in 8 bit chunks.
public static string ToString(string seq)
{
char[] c = seq.ToCharArray();
string result = "";
switch (c[c.Length - 1]) {
case 'b':
string[] par = seq.Replace("b","").Split(' ');
foreach (string str in par) {
char[] tmp = str.ToCharArray();
int dec = 0;
for (int a = 0; a < tmp.Length; a++)
{
if (tmp[a].Equals('1')) {
dec += (int)Math.Pow( 2 , ( (tmp.Length - 1) - a ) );
}
}
result += Convert.ToString((char)dec);
}
break;
default: break;
}
return result;
}//END Method ToString(string seq);
//Pads pure binary sequences to the specified length using 0's
//"110" padded to a width of 4 would be "0110"
private static string Pad(string bin, int width)
{
char[] c = bin.ToCharArray();
if ( c.Length < width )
{
for (int a = 0; a < (width - c.Length); a++)
{
bin = "0" + bin;
}
}
return bin;
}//END Method Pad(string s, int width);
}
}
The "Mono" compatibility framework applies an environment that'll allow C# source code to compile to an executable that the native OS can understand. I'm not sure if it allows other .NET languages as well, but it's a neat project for development abroad. http://www.mono-project.com/Main_Page
It's a surprisingly refreshing language given the similarities. Visual Studio is remarkably nice compared to what I had been using (TextPad, NetBeans, etc..), and is very nice in regards to creating desktop applications thus far. I'll still use Java for somethings, like Applets or others of the like, but C# is more acclimated to Windows (obviously), making many tasks easier.
I'll give it a go.
http://msdn.microsoft.com/en-us/library/windows/apps/hh974581.aspx -- A thorough guide for making Windows Apps with what looks like any Windows based languages. VB, C#, C, C++, HTML/CSS/JS, XAML, etc..
VS Studio has some really nice tools for UI development of Windows Store apps. Templates, and grids of the like. That being said, I like how C# can work more interactively with Windows instead of being bottle-necked like Java seems to be, but that's to be expected since it IS developed by Microsoft. Lol.