• 易犯的错误忘了初始化对象


    错误的代码:
    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++;
                        }
  • 相关阅读:
    BluetoothGetRadioInfo 函数
    BluetoothFindRadioClose 函数
    BluetoothFindNextRadio 函数
    BluetoothFindFirstRadio 函数
    BLUETOOTH_DEVICE_INFO 函数
    BluetoothSetServiceState 函数
    Bluetooth Functions
    union联合体学习
    置顶
    Toppo: 1
  • 原文地址:https://www.cnblogs.com/tianya/p/935827.html
Copyright © 2020-2023  润新知