我正在使用FileHelpers来创建NACHA文件.以下示例
许多属性都是带前导零的数字,因此它们已被定义为字符串.是否有一个属性可以填充Class属性中的前导零,类似于FieldTrim/TrimMode删除空格的方式?
[FixedLengthRecord()]
public class FileControlRecord
{
[FieldFixedLength(1)]
public int RecordTypeCode = 9; //Constant
[FieldFixedLength(6)]
public string BatchCount; //Numeric
[FieldFixedLength(6)]
public string BlockCount; //Numeric
[FieldFixedLength(8)]
public string EntryAddendaCount; //Numeric
[FieldFixedLength(10)]
public string EntryHash; //Numeric
[FieldFixedLength(12)]
public string TotalDebit; //$$$$$$$$$$cc
[FieldFixedLength(12)]
public string TotalCredit; //$$$$$$$$$$cc
[FieldFixedLength(39)]
[FieldNotInFile]
public string RESERVED; //Blank
}
Run Code Online (Sandbox Code Playgroud) 我有一个isGrounded来自我的播放器移动控制脚本的bool变量(),我想在另一个中访问它GameObject.
BallController.cs
public class BallController : MonoBehaviour {
Transform myTrans;
Rigidbody2D myBody;
public bool isGrounded = true;
public bool release = false;
}
Run Code Online (Sandbox Code Playgroud)
GravityPull.cs
public class GravityPull : MonoBehaviour {
public GameObject target;
public int moveSpeed;
public int maxdistance;
private float distance;
void Start ()
{
target= (GameObject.Find("Ball (1)"));
}
void Update ()
{
distance = Vector2.Distance (target.transform.position, transform.position);
if (distance < maxdistance && target.isGrounded)
{
target.transform.position = Vector2.MoveTowards(target.transform.position, transform.position, moveSpeed * Time.deltaTime / distance);
} …Run Code Online (Sandbox Code Playgroud) 有什么方法可以使WPF 中可调整大小的窗口中Header的ExpanderFit 成为最大宽度?看来无论我做什么,我都无法将内容扩展到最大宽度。它Content在Expander.
<Grid Background="LightGray">
<Expander IsExpanded="True">
<Expander.Header>
<Grid Width="100" Height="50">
<Rectangle Fill="Red"></Rectangle>
</Grid>
</Expander.Header>
<Rectangle Fill="Red"></Rectangle>
</Expander>
</Grid>
Run Code Online (Sandbox Code Playgroud) 我有一个 Spring mvc 应用程序,@RestController类似于:
@RestController
@RequestMapping("levels")
public class LevelController {
private final GetLevelOneCount getLevelOneCount;
private final GetLevelTwoCount getLevelTwoCount;
private final GetLevelThreeCount getLevelThreeCount;
@Inject
public LevelController(GetLevelOneCount getLevelOneCount,
GetLevelTwoCount getLevelTwoCount,
GetLevelThreeCount getLevelThreeCount) {
this.getLevelOneCount = getLevelOneCount;
this.getLevelTwoCount = getLevelTwoCount;
this.getLevelThreeCount = getLevelThreeCount;
}
@GetMapping("/level1/{id}")
public LevelModel levelOne(@PathVariable String id) throws SQLException {
LevelModel levelOneModel = new LevelModel();
levelOneModel.setLevelQuery(getLevelOneCount.execute(id));
levelOneModel.setLevelDirQuery(getLevelOneCount.executeDir(id));
levelOneModel.setLevelDateQuery(getLevelOneCount.executeDate(id));
return levelOneModel;
}
Run Code Online (Sandbox Code Playgroud)
我LevelModel是一个带有私有变量的 POJO,现在我想知道,这是否可以序列化为带有私有变量的 propper JSON?
package com.pwc.tag.service.levels;
public class LevelModel {
private Long LevelQuery;
private Long …Run Code Online (Sandbox Code Playgroud) 您好,我在阅读时遇到问题MySqlDataReader。我尝试更改while()为if(),然后它起作用了。所以我做错了while (Reader.Read())。谢谢你的回答。(今天的另一个问题已解决,评论的人帮助了我xd)
using (MySqlCommand cmd = new MySqlCommand
("SELECT * FROM `citationer`", mysqlCon))
{
try
{
MySqlDataReader Reader = cmd.ExecuteReader();
while (Reader.Read()) // this part is wrong somehow
{
citationstexter.Add(Reader.GetString(loopReading)); // this works
loopReading++; // this works
}
Reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Run Code Online (Sandbox Code Playgroud) 我想要一个独立的项目来测试通过 USB 连接的远程系统的一些功能。
所以我想在我的应用程序中使用 NUnit 的所有功能。
我目前是这样写的:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using NUnit.Framework;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.ReadLine();
}
}
[TestFixture]
public class MyTest
{
[Test]
public void MyTest()
{
int i = 3;
Assert.AreEqual(3, i);
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何运行我的测试套件以及如何获得测试报告?
我使用StreamWriter和在新类中创建了一个文本文件WriteLine.我构建的每一行都是这样的:
w.WriteLine("key2" + "=" + value2);
w.WriteLine("key1" + "=" + value1);
Run Code Online (Sandbox Code Playgroud)
然后在form1 Load事件中:
string[] lines = File.ReadAllLines(FileName);
Run Code Online (Sandbox Code Playgroud)
现在我在索引0"key2 = value2"和索引1中的行"key1 = value1"现在我想将每个值分配给另一个字符串,例如:
string1赋值key1的key1和string2赋值key2的key2
有时可以更改行的顺序,文本文件中的第一行可以是value2和key2或value1和key1,但在所有情况下,我希望为字符串value1分配key1的value1,将字符串value2赋值为value2 key2
这次我手动构建了文本文件,没有keyvaluepair或类似的东西但是当读回来时我想读取左边的含义作为键,并且在=作为值之后.
但如果我在做:
string[] lines = File.ReadAllLines(Authentication.AuthenticationFileName);
for (int i = 0; i < lines.Length; i++)
{
}
Run Code Online (Sandbox Code Playgroud)
我怎么知道总是按照我想要的顺序分配字符串无论文本文件中的行是否写入顺序?
我想知道如果我构建像键和值的文本文件它是如何工作的: key = value
c# ×6
.net ×1
connector ×1
filehelpers ×1
java ×1
leading-zero ×1
mysql ×1
nunit ×1
rest ×1
spring ×1
spring-boot ×1
winforms ×1
wpf ×1