Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

mono tutorial code for examples in LXF

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
lis



Joined: Thu Nov 30, 2006 1:50 pm
Posts: 57
Location: Noord Holland, the Netherlands

PostPosted: Thu Dec 28, 2006 12:06 pm    Post subject: mono tutorial code for examples in LXF Reply with quote

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 Shocked

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
View user's profile Send private message
lis



Joined: Thu Nov 30, 2006 1:50 pm
Posts: 57
Location: Noord Holland, the Netherlands

PostPosted: Thu Dec 28, 2006 6:26 pm    Post subject: Reply with quote

Here's another one.
Don't make the textfiles with "touch" & leave them empty Wink


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));
            }
         }
      }
   }
}


Very Happy

I'm enjoying this
Very Happy
Back to top
View user's profile Send private message
lis



Joined: Thu Nov 30, 2006 1:50 pm
Posts: 57
Location: Noord Holland, the Netherlands

PostPosted: Thu Dec 28, 2006 6:48 pm    Post subject: Reply with quote

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 Cool
Back to top
View user's profile Send private message
bren7x64



Joined: Thu Jul 14, 2005 3:51 pm
Posts: 7

PostPosted: Wed Jan 03, 2007 1:01 pm    Post subject: Reply with quote

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 ... Wink
Back to top
View user's profile Send private message
TonyLB
LXF regular


Joined: Tue Apr 12, 2005 8:08 pm
Posts: 112
Location: Wirral, UK

PostPosted: Wed Jan 03, 2007 7:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
zmsc1



Joined: Tue Jan 24, 2006 8:04 pm
Posts: 10

PostPosted: Sat Jan 06, 2007 8:41 am    Post subject: System.IO.File does not contain a definition for ReadAllText Reply with quote

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
View user's profile Send private message
jjmac
LXF regular


Joined: Fri Apr 08, 2005 2:32 am
Posts: 1996
Location: Sydney, Australia

PostPosted: Sat Jan 06, 2007 9:37 am    Post subject: RE: System.IO.File does not contain a definition for ReadAll Reply with quote

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 Evil or Very Mad Evil or Very Mad


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
View user's profile Send private message
lis



Joined: Thu Nov 30, 2006 1:50 pm
Posts: 57
Location: Noord Holland, the Netherlands

PostPosted: Sun Jan 07, 2007 10:15 am    Post subject: Reply with quote

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
View user's profile Send private message
lis



Joined: Thu Nov 30, 2006 1:50 pm
Posts: 57
Location: Noord Holland, the Netherlands

PostPosted: Sun Jan 07, 2007 10:34 am    Post subject: Reply with quote

Hi Bren7x64,

Gee I'm sorry I made you think again Wink

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 Crying or Very sad

greetz,
Lis
Wink
Back to top
View user's profile Send private message
zmsc1



Joined: Tue Jan 24, 2006 8:04 pm
Posts: 10

PostPosted: Mon Jan 08, 2007 9:04 pm    Post subject: Thanks lis ... Reply with quote

... 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
View user's profile Send private message
lis



Joined: Thu Nov 30, 2006 1:50 pm
Posts: 57
Location: Noord Holland, the Netherlands

PostPosted: Wed Jan 10, 2007 7:48 pm    Post subject: Reply with quote

Hi Stuart,
I'm sorry, but I am really not interested in Windows. Rolling Eyes
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
View user's profile Send private message
DacidJ



Joined: Thu Jan 11, 2007 11:39 pm
Posts: 1

PostPosted: Thu Jan 11, 2007 11:52 pm    Post subject: Reply with quote

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 Sad
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 Wink
Back to top
View user's profile Send private message
lis



Joined: Thu Nov 30, 2006 1:50 pm
Posts: 57
Location: Noord Holland, the Netherlands

PostPosted: Fri Jan 12, 2007 6:40 pm    Post subject: mono debugger Reply with quote

I guess you've allready checked this out:
http://www.monodevelop.com/Enabling_the_Debugger

Dated june 2006. So maybe things have changed.

Lis
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast