| View previous topic :: View next topic |
| Author |
Message |
lis

Joined: Thu Nov 30, 2006 1:50 pm Posts: 57 Location: Noord Holland, the Netherlands
|
Posted: Thu Dec 28, 2006 12:06 pm Post subject: mono tutorial code for examples in LXF |
|
|
Hi there,
I thought it might be a good idea to post the code of the examples Paul gives, and that are not on the DVD, ... since I spent hours trying to find what went wrong,
installing and uninstalling distro A and distro B, package C,D,E and F etc etc,
when in the end I had just forgotten to put the added code in braces
So to help others save some time, by showing them the code that actually works, I'm posting it here.
| Code: |
// project created on 12/27/2006 at 2:35 PM
using System;
using System.IO;
namespace inputOutput
{
class inputOutput
{
public static void Main(string[] args)
{
string myIOfile = File.ReadAllText("myIOfile.txt");
Console.Write(myIOfile);
}
}
}
|
That's all for the first example in LXF 88.
greetz,
Lis |
|
| Back to top |
|
 |
lis

Joined: Thu Nov 30, 2006 1:50 pm Posts: 57 Location: Noord Holland, the Netherlands
|
Posted: Thu Dec 28, 2006 6:26 pm Post subject: |
|
|
Here's another one.
Don't make the textfiles with "touch" & leave them empty
| Code: |
// project created on 12/28/2006 at 5:13 PM
// This app. reads the contents of certain files in a given directory,
// and writes all its contents to screen.
using System;
using System.IO;
namespace forEachLoop
{
class forEachLoop
{
public static void Main(string[] args)
{
string[] files = Directory.GetFiles("/home/lis/Documents");
foreach (string file in files)
{
if(file.EndsWith(".txt"))
{
Console.Write(File.ReadAllText(file));
}
}
}
}
}
|
I'm enjoying this  |
|
| Back to top |
|
 |
lis

Joined: Thu Nov 30, 2006 1:50 pm Posts: 57 Location: Noord Holland, the Netherlands
|
Posted: Thu Dec 28, 2006 6:48 pm Post subject: |
|
|
I tried some stuff from the information Paul gave with the mono tutorial in LXF 88.
| Code: |
// project created on 12/28/2006 at 4:20 PM
using System;
using System.IO;
namespace conditionalStatementsAndLoops
{
class conditionalStatementsAndLoops
{
public static void Main(string[] args)
{
string conditie = File.ReadAllText("conditie.txt");
conditie += "\nHey .. With this ONE program I'm sending output in two directions; part of it lands in a file and another part to screen .. Kewl !";
File.WriteAllText("conditie.txt", conditie);
Console.Write(conditie);
Console.WriteLine("\n");
for (int i = 1; i <= 16; ++i)
{
Console.WriteLine("Thunder..");
}
Console.WriteLine("Thundercats ! HO !\n");
Console.WriteLine("But this gooblygoock is not being written to the file conditie.txt terecht :-) !");
}
}
}
|
Sorry !! I could not resist trying it and posting it !!
Must be getting addicted  |
|
| Back to top |
|
 |
bren7x64
Joined: Thu Jul 14, 2005 3:51 pm Posts: 7
|
Posted: Wed Jan 03, 2007 1:01 pm Post subject: |
|
|
Not specifically in reply to your posts, but, I am a long-time M$ hater and I cannot believe that anything out of Redmond is worth anything - having seen the ease with which one can accomplish things in C#, I have to re-evaluate my position ... - DAMN - I HATE having to think again ...  |
|
| Back to top |
|
 |
TonyLB LXF regular
Joined: Tue Apr 12, 2005 8:08 pm Posts: 111 Location: Wirral, UK
|
Posted: Wed Jan 03, 2007 7:44 pm Post subject: |
|
|
Some of the stuff in C# is great. You can see that it has progressed from both Java and C++ (I love the @ to make strings literal between the start and end quotes, no escaping). But others really suck and you wonder why they didn't stick with the Java way of doing things.
Tony _________________ In the beginning was nothing, which exploded! (Lords and Ladies, Terry Pratchett) |
|
| Back to top |
|
 |
zmsc1
Joined: Tue Jan 24, 2006 8:04 pm Posts: 10
|
Posted: Sat Jan 06, 2007 8:41 am Post subject: System.IO.File does not contain a definition for ReadAllText |
|
|
Hi, I'm trying the code you posted, but it won't compile, giving error message 'System.IO.File' does not contain a definition for ReadAllText. As this is my first ever bit of C#, I seem to be stuck pretty early on!
Any pointers appreciated.
Stuart |
|
| Back to top |
|
 |
jjmac LXF regular
Joined: Fri Apr 08, 2005 2:32 am Posts: 1996 Location: Sydney, Australia
|
Posted: Sat Jan 06, 2007 9:37 am Post subject: RE: System.IO.File does not contain a definition for ReadAll |
|
|
TonyLB wrote:
>>
you wonder why they didn't stick with the Java way of doing things.
>>
I think they may well have had there reasons
jm _________________ http://counter.li.org
#313537
The FVWM wm -=- www.fvwm.org -=-
Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ... |
|
| Back to top |
|
 |
lis

Joined: Thu Nov 30, 2006 1:50 pm Posts: 57 Location: Noord Holland, the Netherlands
|
Posted: Sun Jan 07, 2007 10:15 am Post subject: |
|
|
Hi Stuart,
The error message you mention, is what gets returned to you when you forgot to set Monodevelop's configuration to save the executable files in the same directory as the project.
Check issue 88, monotutorial, page 94 and 95 under "feel the magic";
| Quote: |
While you're in this window, ....... that it removes the /bin/Debug section.
|
This is just one of the possible causes of your error message though.
(I also got it when I forgot to put the braces in the right spot.)
greets,
Lis |
|
| Back to top |
|
 |
lis

Joined: Thu Nov 30, 2006 1:50 pm Posts: 57 Location: Noord Holland, the Netherlands
|
Posted: Sun Jan 07, 2007 10:34 am Post subject: |
|
|
Hi Bren7x64,
Gee I'm sorry I made you think again
But thanks for the information; I had no idea C# was a product of the B.Gates factory. It does make me a bit more cautious.
I'm still mourning for OS/2
greetz,
Lis
 |
|
| Back to top |
|
 |
zmsc1
Joined: Tue Jan 24, 2006 8:04 pm Posts: 10
|
Posted: Mon Jan 08, 2007 9:04 pm Post subject: Thanks lis ... |
|
|
... I'm trying to follow the tutorial on a Windows PC - assuming that as this is cross platform, all will be exactly the same. So I don't have the Monodevelop IDE. But I can compile a helloworld and the executable is written to the same directory as the source was in. And the exe runs correctly. And I've done a cut and paste on the code you posted to make sure the braces can't be in the wrong place - but I still get the same error.
I could restart my PC and load up SLED which is the dual boot alternative, then I dare say it would work, but I'm not really trying to prove that Mono works on Linux - I believe that bit - what I really want to show is that Mono works just the same on Windows.
Stuart |
|
| Back to top |
|
 |
lis

Joined: Thu Nov 30, 2006 1:50 pm Posts: 57 Location: Noord Holland, the Netherlands
|
Posted: Wed Jan 10, 2007 7:48 pm Post subject: |
|
|
Hi Stuart,
I'm sorry, but I am really not interested in Windows.
However:
You seem to be sure it would work in SuSE (gnome), mono and monoDevelop, so I think the best thing for you to solve the problem, is try it yourself by booting into SuSE Linux, and see what's different from your windows version.
GoodLuck.
Lis |
|
| Back to top |
|
 |
DacidJ
Joined: Thu Jan 11, 2007 11:39 pm Posts: 1
|
Posted: Thu Jan 11, 2007 11:52 pm Post subject: |
|
|
Does anybody know? Is there a debugger that integrates with "monoDevelop"?
moneDevelop is a very nice ide, but if there is not a debugger then its not very "i"
And yes I know about mint, but that is CLI and doesn't feel right with the monoDevelop GUI
Why do I want this? because I am trying to teach my son(11) to program and C# looks good for this. But I know that he wont like a CLI debugger
Maybe we will stick with C/C++, but it is TOO easy to write dodgy programs in these languages. ( I know - its my dayjob ) dodgy programmer R us  |
|
| Back to top |
|
 |
lis

Joined: Thu Nov 30, 2006 1:50 pm Posts: 57 Location: Noord Holland, the Netherlands
|
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|