How to run a very simple C# code in ZennoPoster

lupo

Client
Регистрация
28.05.2012
Сообщения
72
Благодарностей
32
Баллы
18
Hello,
as many other ZennoPoster users I'm not a coder and I decided to start learning C# in order to use it in my templates ...
Would somebody help me how to run my first C# lesson in ZennoPoster?

Код:
using System;

namespace HelloCSharp2
{
    class HelloCSharp2
    {
        static void Main()
        {
            Console.WriteLine("Hello CShapr!");
        }
    }
}
or the same code here:
Код:
using System;

    class HelloCSharp2
    {
        static void Main()
        {
            Console.WriteLine("Hello CShapr!");
        }
    }
This code is working in Visual C# 2010 but in ZennoPoster I receive only errors :-)
I have added GAC Reference to System.dll but the Error is the same.

 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113
There is explanation what i got from DD some time ago.

It was enough for me to understand what is what :-)

ZennoPoster snippet is Regular C# class
It looks like




JavaScript:
using System;
using System.Collections.Generic;
 using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using ZennoLab.CommandCenter;
using ZennoLab.InterfacesLibrary;
 using ZennoLab.InterfacesLibrary.ProjectModel;
using ZennoLab.InterfacesLibrary.ProjectModel.Collections;
using ZennoLab.InterfacesLibrary.ProjectModel.Enums;
using ZennoLab.Macros;
 using Global.ZennoExtensions;
using ZennoLab.Emulation;


namespace ZennoLab.OwnCode
{
    public class C_SOME_RANDOM_CLASS_NAME
    {
        /// <summary> lock this object to mark part of code for single thread execution </summary>
         private static object SyncObject = new object();


        public object M_SOME_RANDOM_METHOD_NAME(IZennoPosterProjectModel project, Instance instance)
        {
   // OWN CODE HERE

             return "ok";
        }
    }
}
 
  • Спасибо
Реакции: lupo

Stroks

Client
Регистрация
09.02.2012
Сообщения
219
Благодарностей
14
Баллы
18
Cool explanation.

For example if you need reference for System.Web you for lets say encoding function such as HttpUtility.UrlEncode(URL) you can reference System.Web in Zenno (if you use other the might be already referenced) and call i System.Web.HttpUtility.UrlEncode(URL). I am not an expert but this almost always work.
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)