当我期待0,1,2,3时,控制台显示0,0,0,0.
这是以下版本的修改版本:https://msdn.microsoft.com/en-us/library/system.io.binarywriter(v=vs.110).aspx
using System;
using System.IO;
namespace testingfilereadwrite
{
class Program
{
const string FileName = "TestFile.dat";
static void Main()
{
WriteDefaultValues();
DisplayValues();
Console.ReadKey();
}
public static void WriteDefaultValues()
{
using (BinaryWriter writer = new BinaryWriter(File.Open(FileName, FileMode.Create)))
{
writer.Write(0);
writer.Write(1);
writer.Write(2);
writer.Write(3);
}
}
public static void DisplayValues()
{
byte byte1;
byte byte2;
byte byte3;
byte byte4;
if (File.Exists(FileName))
{
using (BinaryReader reader = new BinaryReader(File.Open(FileName, FileMode.Open)))
{
byte1 = reader.ReadByte();
byte2 = reader.ReadByte();
byte3 = reader.ReadByte(); …Run Code Online (Sandbox Code Playgroud) 我确信在我不知道正确的表达方式之前已经有人问过这个问题,所以我找不到我要找的东西。
我有一个类,其中有一个字段,我希望能够从外部看到该字段,但无法直接修改它。
public class myclass
{
public int value;
public void add1()
{
value = value + 1;
}
}
Run Code Online (Sandbox Code Playgroud)
所以我真的希望只可以从方法中修改add1()“值”字段,但我仍然希望能够看到“值”的值。
编辑:我认为只能通过类进行修改myclass,但我输入了其他内容。感谢您指出了这一点。
这就是我用来根据枚举类型选择函数的方法。有没有我没有切换CalcMe功能的方法?
namespace ClassLibrary1
{
public class Playbox
{
//types:
//0 - red hair
//1 - blue hair
//defines function to input based on hairtype.
//red:
// input*10
//blue:
// input*12
public enum Phenotypes
{
red,
blue
}
static public int Red(int input)
{
return input*10;
}
static public int Blue(int input)
{
return input*12;
}
static public int CalcMe(Phenotypes phenotype, int input)
{
switch (phenotype)
{
case Phenotypes.red:
return Red(input);
case Phenotypes.blue:
return Blue(input);
default:
return 0;
} …Run Code Online (Sandbox Code Playgroud) 我会在前面说我发现的所有文档都不适用于我的 Oracle 版本: https: //docs.oracle.com/cd/E51711_01/DR/WeekDay.html; https://docs.oracle.com/cd/E37483_01/server.751/es_eql/src/ceql_functions_date_extract.html
或者我可以使用的函数参考不要提及星期几: https ://docs.oracle.com/cd/B28359_01/server.111/b28286/functions052.htm#SQLRF00639
所以我只是想办法使用to_char来做到这一点,然后进行 varchar2 比较。如果可能的话,我想坚持使用日期格式。
到目前为止这是我的sql
select dateSold from sales
where extract(dateSold, day_of_week) in (1, 3, 4, 7)
SQL Error: ORA-00904: "DAY_OF_WEEK": invalid identifier
Run Code Online (Sandbox Code Playgroud)