You are not logged in.
Pages: 1
how can I compile a singe C# source file in arch?
I don't want to use mono. It doesn't like the Console.ReadKey(); lines.
Here's the file: (quicksort)
using System;
using System.Collections.Generic;
using System.Text;
namespace bubble
{
class Program
{
//number of numbers to sort
//int max = 100;
//method to generate random array
static int[] MakeArray(int[] rndmArray, int max)
{
Random rand = new Random();
for (int n = 0; n < max; n++)
rndmArray[n] = rand.Next();
return rndmArray;
}
static void Main(string[] args)
{
//generate random array
Console.WriteLine("Enter the number of integers to sort");
int max = int.Parse(Console.ReadLine());
Console.WriteLine("Generating random array with {0} numbers...", max);
int[] array2 = new int[max];
array2 = MakeArray(array2, max);
Console.WriteLine("Press any key to sort {0} numbers", max);
Console.ReadKey();
Console.WriteLine("Sorting...");
Console.WriteLine();
array2= quicksort(array2, 0, max-1);
//write sorted array
foreach (int n in array2)
Console.WriteLine(n);
Console.WriteLine();
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
public static int[] quicksort(int[] sortMe, int begin, int end)
{
int left = begin;
int right = end;
int test = sortMe[right];
int pivot = sortMe[left];
//moves numbers larger than pivot to end of array, and ones smaller to beginning, and puts pivot in last spot
while (left < right)
{
//if the test number is greater than pivot move to end
if (test > pivot)
{
sortMe[right] = test;
right--;
test = sortMe[right];
}
//if the test number is less than pivot move to beginning
else
{
sortMe[left] = test;
left++;
test = sortMe[left];
}
}
sortMe[left] = pivot;
//keeps calling quicksort until all sections of array have one number
if (left - begin > 1)
{
quicksort(sortMe, begin, left - 1);
}
if (end - right > 1)
{
quicksort(sortMe, right + 1, end);
}
//return sorted array
return sortMe;
}
}
}
Last edited by Raccoon1400 (2009-03-12 02:21:12)
Fustrated Windows users have two options.
1. Resort to the throwing of computers out of windows.
2. Resort to the throwing of windows out of computers.
Offline
I think for C# mono might be your only option, unless you want to run Windows + Visual Studio in a Virtual Machine just for that, which I'm sure you don't
It should be as easy as running "gmcs source.cs", I'm not sure why the ReadKey line would fail. I'll test that out myself now.
Edit: Yeah I saved your file as test.cs and ran "gmcs test.cs" and it compiled fine, and running "mono test.exe" gave the intended output.
Last edited by HashBox (2009-03-11 22:25:13)
Offline
I was using smcs instead of gmcs. What's the difference?
Fustrated Windows users have two options.
1. Resort to the throwing of computers out of windows.
2. Resort to the throwing of windows out of computers.
Offline
I hadn't heard of smcs until I looked it up, although I knew of mcs. According to the Mono website, this is the difference:
mcs: compiler to target 1.1 runtime.
gmcs: compiler to target the 2.0 runtime.
smcs: compiler to target the 2.1 runtime, to build Moonlight applications.
Although I would've assumed that a 2.1 runtime contained nearly the same stuff as the 2.0 runtime, but they seem to be different. Well you learn something new every day
Edit: Here's a slightly better explanation from the bottom of the page (http://mono-project.com/CSharp_Compiler):
mcs: references the 1.0-profile libraries (the APIs as defined in 1.1) and supports C# 1.0 and C# 3.0 minus generics and any features that depends on generics.
gmcs: references the 2.0-profile libraries (the APIs as defined in 2.0 and 3.5) and exposes the full C# 3.0 language.
smcs: references the 2.1-profile libraries (the APIs defined for Silverlight) and exposes the full C# 3.0 language. This is the compiler used for creating Silverlight/Moonlight applications.
Last edited by HashBox (2009-03-11 23:27:28)
Offline
gmcs likes the ReadKey line, but I can't use that line if I use smcs.
This solves the issue.
Fustrated Windows users have two options.
1. Resort to the throwing of computers out of windows.
2. Resort to the throwing of windows out of computers.
Offline
Pages: 1