我一直收到annualRate,monthlyCharge和lateFee的错误.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Lab_5___Danny_Curro
{
    class Program
    {
        static void Main(string[] args)
        {
            string firstName;
            string lastName;
            int accNumber;
            string creditPlan;
            double balance;
            string status;
            Boolean late = false;
            double lateFee;
            double monthlyCharge;
            double annualRate;
            double netBalance;
            Console.Write("Enter First Name: ");
            firstName = Console.ReadLine();
            Console.Write("Enter Last Name: ");
            lastName = Console.ReadLine();
            Console.Write("Enter Account Number: ");
            accNumber = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter Credit Card Plan Number[Blank Will Enter Plan 0]: ");
            creditPlan = Console.ReadLine();
            Console.Write("Enter Balance: …似乎没有办法分配NULL(变量的" 未赋值 ")TDateTime.
我想象的唯一方法是使用这样的东西:
function isNull(aDate : TDateTime) : boolean;
const NullDate = 0.0;
var aNullDate : TDatetime;
    ms : Int64;
begin
  aNullDate := NullDate;
  ms := MilliSecondsBetween(aDate,aNullDate);
  result := (ms = Int64(0));
end;
是否有谁知道更好的解决方案什么不重叠0日期值?
负值是TDateTime危险的吗?(作为以前用途的能力资源)
我是编程新手并遇到以下代码问题的新手:
    private string alphaCoords(Int32 x)
    {
        char alphaChar;
        switch (x)
        {
            case 0: alphaChar = 'A'; break;
            case 1: alphaChar = 'B'; break;
            case 2: alphaChar = 'C'; break;
            case 3: alphaChar = 'D'; break;
            case 4: alphaChar = 'E'; break;
            case 5: alphaChar = 'F'; break;
            case 6: alphaChar = 'G'; break;
            case 7: alphaChar = 'H'; break;
            case 8: alphaChar = 'I'; break;
            case 9: alphaChar = 'J'; break;
        }
        return alphaChar.ToString();
    }
编译器说:使用未分配的局部变量'alphaChar'
但我正在我的交换机块中分配它.
我确定这是我的错,因为我对编程知之甚少.
请指教.
谢谢.
只是好奇.
如果你走的话:
string myString;
它的值为null.
但如果你去:
int myInt;
C#中此变量的值是多少?
谢谢
大卫
i在这个例子中什么时候可以取消分配?
int i;
try
{
    i = 2;
}
catch
{
    i = 3;
}
finally
{
    string a = i.ToString();
}
错误是在for循环中引起的:
for (i = 0; i < hand.Length; i++)
{
   Console.WriteLine(hand[i]);
}
我试图存储值,以便以后显示它们.写作线可以帮助我确保代码实际上按照我的意图运行.
其余代码供参考:*编辑:添加了一行代码
enum house //variable type for the card type
{
    Spades, Hearts, Clubs, Diamonds
}
enum cards //variable type for the cards
{
    Joker, Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King
}
class Program
{
    static void Main(string[] args)
    {
        Random rnd;
        Random rnd2;
        int i;
        int random;
        int random2;
        String[] hand;
        house randomhouse;
        cards randomcard;
        //all declared variables
        Console.WriteLine("Your hand …为什么这个声明+赋值会导致错误:
// Use of unassigned local variable 'handler'.
SessionEndingEventHandler handler = (sender, e) => { isShuttingDown = true; SystemEvents.SessionEnding -= handler; };
虽然这不是:
SessionEndingEventHandler handler = null;
handler = (sender, e) => { isShuttingDown = true; SystemEvents.SessionEnding -= handler; };
直观地说,第一个语句应该导致错误但不能立即清楚为什么第二个语句不是.
此外,SystemEvents.SessionEnding在调用之后,如何判断事件是否实际上已取消订阅handler(null, null)?该GetInvocationList只适用于委托.
SystemEvents.SessionEnding += handler;
handler(null, null);
有这个代码,我不明白为什么如果在finally块中分配变量不理解它将始终被分配.我想我错过了一个无法分配货币的有效选项.如果你知道,理解为什么会很棒.非常感谢!
谢谢!
CurrencyVO currency;
try
{
     if (idConnection.HasValue && idConnection != 0)
     {
         currencyConnection = client.GetConnection(idConnection.Value);
         model.Connection = currencyConnection;
     }
     else 
     {
         int providerUserKey = (int)Models.UserModel.GetUser().ProviderUserKey;
         currencyConnection = client.GetConnection(providerUserKey);
     }                        
     currency = model.Currencies.SingleOrDefault(c => c.IdCountry == currencyConnection.idcountry) ?? new CurrencyVO();    
} 
catch
{
      currency = new CurrencyVO();                    
} 
finally
{
      model.PublishedContainer.Currency = currency;
}
finally块上发生错误.如果我把它从finally块中取出来像这样:
                } catch {
                    currency = new CurrencyVO();
                }
                model.PublishedContainer.Currency = currency;
它工作正常.
我正在从我的App.config文件中读取连接字符串,为此我有以下代码.
try
 {
    string[] dbnames;
    int counter = 0;
    foreach (ConnectionStringSettings connSettings in ConfigurationManager.ConnectionStrings) 
    {
        dbnames[counter] = connSettings.Name;
        counter++;
    }
    return dbnames;
 }
 catch
 {
    throw;
 }
这段代码让我错误地使用了未分配的dbnames局部变量.我将在App.config中有多个连接字符串.它们可以是无,1,2等等.根据需要.所以我不能静态分配dbname大小.因为如果超过指定大小的值,可能会出现这种情况.例如.如果我指定它的大小为5,如果我得到第6个连接字符串怎么办?如果我有1,那么剩下的4将是记忆的浪费.
如果我错了,请告诉我.
谢谢.
我刚开始学习 Fortran,遇到了这个问题。考虑下面的简单代码。
PROGRAM random
INTEGER, DIMENSION(12):: array
PRINT *, array
END PROGRAM random
将array未分配的值,但可以打印,它似乎有一些随机的因素和一些零元素。但是,如果我考虑更短的数组,请说我声明
INTEGER, DIMENSION(5):: array
那么打印的数组的所有元素都为 0。我想知道这里发生了什么?