igenotype.cs

来自「Generalization of a Simple Genetic Algor」· CS 代码 · 共 59 行

CS
59
字号
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;

namespace GeneticAlgorithmLib
{
    public interface IGenotype
    {
        [Editor(typeof(CollectionEditor), typeof(UITypeEditor))]
        List<Gene> Genes { get; }
    }
    public class Gene
    {
        public Gene(string Name, EGene Value)
        {
            this.m_NameString = Name;
            this.m_Value = Value;
        }
        #region NameString
        private string m_NameString;
        public string NameString
        {
            get { return m_NameString; }
        }
        #endregion
        #region Value
        private EGene m_Value;
        public EGene Value
        {
            get { return m_Value; }
        }
        #endregion
        #region Name
        public string Name
        {
            get { return this.ToString(); }
        }
        #endregion
        public override string ToString()
        {
            return string.Format("{0} - {1}", 
                this.NameString, this.Value == EGene.On ? "Sum" : "Prod");
        }
        public void SetGene(EGene Gene)
        {
            this.m_Value = Gene;
        }
    }
    [Flags]
    public enum EGene
    {
        Off = 0,
        On = 1,
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?