Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2004, 08:51 PM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default Help with classes and Objects

hi.. I really don't understand a lot of this C# classes stuff. I only did JScript before. Anyway I started reading and I just can't get this code to work. What's wrong with the classes? (this is kind of a repost but no answers helped me in the previous)

using System;
using Microsoft.CSharp;

class DeclareArraysSample
{
    public static void Main() {
    string[] codeS = new string[9];
    string[] nameS = new string[9];

    codeS[0] = "using System;";
    codeS[1] = "class DeclareArraysSample";
    codeS[2] = "{";
    codeS[3] = " public static void Main()";
    codeS[4] = " {";
    codeS[5] = " byte[][] Nos = new byte[11][];";
    codeS[6] = " Console.WriteLine('Nos-length: {0}',Nos.Length);";
    codeS[7] = " };";
    codeS = "};";

    nameS[0] = "Line 0";
    nameS[1] = "Line 1";
    nameS[2] = "Line 2";
    nameS[3] = "Line 3";
    nameS[4] = "Line 4";
    nomes[5] = "Line 5";
    nameS[6] = "Line 6";
    nameS[7] = "Line 7";
    nameS = "Line 8";

    CompilerError[] ANSWR = Compiler.Compile(codeS,nameS,"sdCOMPILADO.exe",nul l,null);
    }
}
 
Old November 4th, 2004, 03:18 AM
Kep Kep is offline
Authorized User
 
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What do you mean "this code doesn't work"?

Do you mean it doesn't compile? It fails at run-time?

I'm not sure what you're trying to do?


Kep.
 
Old November 4th, 2004, 09:46 AM
Authorized User
 
Join Date: Jul 2003
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

ho! it doesn't compile..

It complains about the sintax in the last command.

it is supossed to compile the codsS array in run time and create an exe.. this Compiler class has a Compile method that does that.. And it all (is suposed to) works under Microsoft.CSharp namespace.

I just don't know why it doesn't compile.
will some of you try to compile it and check it out to tell me?

THANKS
 
Old November 4th, 2004, 06:43 PM
Kep Kep is offline
Authorized User
 
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got your code to compile as given. All I had to do was add a reference to the Managed C# Compiler in the GAC.

Kep.





Similar Threads
Thread Thread Starter Forum Replies Last Post
classes dhoward VB.NET 2002/2003 Basics 2 November 8th, 2006 10:35 AM
About Classes. wdw BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 July 29th, 2005 08:46 AM
Classes digby_dog VB.NET 2002/2003 Basics 1 May 2nd, 2005 09:12 PM
Dynamically Creating Objects of Array of Classes dinkarsinha General .NET 0 January 28th, 2005 06:22 AM
Creating new objects from existing classes module0000 Beginning VB 6 3 June 17th, 2003 07:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.