zoukankan      html  css  js  c++  java
  • 易犯的错误忘了初始化对象

    错误的代码:
    UpdateApplicationInfo[] uai = new UpdateApplicationInfo[3];
                        int position = 0;
                        foreach (DictionaryEntry de in ht)
                        {
                            uai[position].ApplicationGUID = de.Key.ToString();
                            uai[position].Version = de.Value.ToString();
                            position++;
                        }

    正确的:
    UpdateApplicationInfo[] uai = new UpdateApplicationInfo[3]; //只是分配了地址,但是没有指向正确的对象,因为还没有分配对象
                        for (int i = 0; i < 3; i++)
                        {
                            uai[i] = new UpdateApplicationInfo(); //注意分别初始化对象
                        }
                        int position = 0;
                        foreach (DictionaryEntry de in ht)
                        {
                            uai[position].ApplicationGUID = de.Key.ToString();
                            uai[position].Version = de.Value.ToString();
                            position++;
                        }
  • 相关阅读:
    字符串处理(包括正则生成工具)
    php.ini 个别字段笔记
    php-5.4 升级到 php7.2
    【mysql笔记】针对 group_concat 长度限制
    七牛,前端上传图片
    PHP 替换 特殊空白符
    【代码块】定时任务<swoole> 100%无人值守
    安装nodejs
    linux安装beanstalkd
    个人笔记上传 -- redis安装
  • 原文地址:https://www.cnblogs.com/tianya/p/935827.html
Copyright © 2011-2022 走看看