Skip to content

Instantly share code, notes, and snippets.

View JoshClose's full-sized avatar

Josh Close JoshClose

View GitHub Profile
@JoshClose
JoshClose / Game1.cs
Created October 30, 2017 20:04
MonoGame draw issue
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Game1
{
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
void Main()
{
using (var stream = new MemoryStream())
using (var writer = new StreamWriter(stream))
using (var reader = new StreamReader(stream))
using (var csv = new CsvReader(reader))
{
writer.WriteLine("Id,,Name");
writer.WriteLine("1,,one");
writer.WriteLine("2,,two");
void Main()
{
using (var stream = new MemoryStream())
using (var writer = new StreamWriter(stream))
using (var reader = new StreamReader(stream))
using (var csv = new CsvReader(reader))
{
writer.WriteLine("X,Y,Z");
writer.WriteLine("1.23e-15,2.34e-15,3.45e-15");
writer.Flush();
@JoshClose
JoshClose / Example.cs
Created May 17, 2019 18:00
CsvHelper writing dictionary values
void Main()
{
var records = new List<Dictionary<string, string>>
{
new Dictionary<string, string> { { "Id", "1" }, { "Name", "one" } },
new Dictionary<string, string> { { "Id", "2" }, { "Name", "two" } }
};
using (var writer = new StringWriter())
using (var csv = new CsvWriter(writer))
{
void Main()
{
var s = new StringBuilder();
s.AppendLine("Id,Name,A,B,C");
s.AppendLine("1,one,9,8,7");
s.AppendLine("2,two,6,5,4");
using (var reader = new StringReader(s.ToString()))
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
csv.Configuration.RegisterClassMap<FooMap>();
@JoshClose
JoshClose / dotnetlayout.md
Created April 25, 2022 16:17 — forked from davidfowl/dotnetlayout.md
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/