stackoverflow1453

Programming&&Games&&Life

Archive for November, 2015

Dictionary

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ArrayListTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var sozluk = new Dictionary<int, string>();
            sozluk.Add(3, "portakal");
            sozluk.Add(5, "Fındık");
            sozluk.Add(6, "Totis");

            if (sozluk.ContainsKey(3))
            {
                Console.WriteLine("key found");
            }
        }
    }
}

as keyword

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ArrayListTest
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList a = new ArrayList();
            a.Add("Ahmet");
            a.Add("Mehmet");

            foreach (var item in a)
            {
                //string deger = (string)item;
                string deger = item as string;
                Console.WriteLine(deger);
            }
            Console.ReadLine();
        }        
    }
}

ArrayList-2

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ArrayListTest
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList a = new ArrayList();
            a.Add("Ahmet");
            a.Add("Mehmet");

            print(a);

        }

        public static void print(ArrayList m)
        {
            foreach (var item in m)
            {
                Console.WriteLine(item);
            }
        }
    }
}

ArrayList-1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ArrayListTest
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList a = new ArrayList();
            a.Add("Ahmet");
            a.Add("Mehmet");
            foreach (var item in a)
            {
                Console.WriteLine(item.ToString());
            }

            Console.WriteLine(a.Count);
        }
    }
}

Calling R functions from C# program using RDotNet Library

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using RDotNet;

namespace WindowsFormsApplication18
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            REngine.SetEnvironmentVariables();            
            REngine engine = REngine.GetInstance();

            engine.Evaluate("require(stats)");            
            engine.Evaluate("plot(sin, -pi, 2*pi)");
            
        }
    }
}