How to run a very simple C# code in ZennoPoster

  • Автор темы Автор темы lupo
  • Дата начала Дата начала

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.

 
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
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.
 

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