第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

C#錯(cuò)誤:“非靜態(tài)字段,方法或?qū)傩孕枰獙?duì)象引用”

C#錯(cuò)誤:“非靜態(tài)字段,方法或?qū)傩孕枰獙?duì)象引用”

C#
慕桂英546537 2019-11-19 08:43:07
我有兩個(gè)類,一個(gè)用于定義算法參數(shù),另一個(gè)用于實(shí)現(xiàn)算法:第1類(算法參數(shù)):using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace VM_Placement{    public static class AlgorithmParameters    {        public static int pop_size = 100;        public static double crossover_rate = 0.7;        public static double mutation_rate = 0.001;        public static int chromo_length = 300;        public static int gene_length = 4;        public static int max_allowable_generations = 400;        static Random rand = new Random();        public static double random_num = rand.NextDouble();    }}第2類(實(shí)現(xiàn)算法):using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace VM_Placement{    public class Program    {        public struct chromo_typ        {            public string   bits;            public float    fitness;            //public chromo_typ(){            // bits = "";            // fitness = 0.0f;            //}            chromo_typ(string bts, float ftns)            {                bits = bts;                fitness = ftns;            }        };        public static int GetRandomSeed()        {            byte[] bytes = new byte[4];            System.Security.Cryptography.RNGCryptoServiceProvider rng =              new System.Security.Cryptography.RNGCryptoServiceProvider();            rng.GetBytes(bytes);            return BitConverter.ToInt32(bytes, 0);        }        public string GetRandomBits()        {            string bits="";            for (int i = 0; i < VM_Placement.AlgorithmParameters.chromo_length; i++)            {                if (VM_Placement.AlgorithmParameters.random_num > 0.5f)                    bits += "1";                else                    bits += "0";            }            return bits;        }我對(duì)得到一個(gè)錯(cuò)誤Population[i].bits = GetRandomBits();在Main()。錯(cuò)誤是:非靜態(tài)字段,方法或?qū)傩?#39;VM_Placement.Program.GetRandomBits()'需要對(duì)象引用。我有什么想念的嗎?
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 768 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)