mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-06 06:43:47 +00:00
Initial commit
This commit is contained in:
parent
d0eb68594c
commit
c0d4d11b54
24 changed files with 463 additions and 0 deletions
53
vscode/Chapter07/AssembliesAndNamespaces/Program.cs
Normal file
53
vscode/Chapter07/AssembliesAndNamespaces/Program.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using System.Xml.Linq; // XDocument
|
||||
using System; // String
|
||||
using Packt.Shared; // IsValidHex(), IsValidXmlTag(), IsValidPassword()
|
||||
using DialectSoftware.Collections;
|
||||
using DialectSoftware.Collections.Generics;
|
||||
|
||||
XDocument doc = new();
|
||||
|
||||
string s1 = "Hello";
|
||||
String s2 = "World";
|
||||
WriteLine($"{s1} {s2}");
|
||||
|
||||
Write("Enter a color value in hex: ");
|
||||
string? hex = ReadLine(); // or "00ffc8"
|
||||
WriteLine("Is {0} a valid color value? {1}",
|
||||
arg0: hex, arg1: hex.IsValidHex());
|
||||
|
||||
Write("Enter a XML element: ");
|
||||
string? xmlTag = ReadLine(); // or "<h1 class=\"<\" />"
|
||||
WriteLine("Is {0} a valid XML element? {1}",
|
||||
arg0: xmlTag, arg1: xmlTag.IsValidXmlTag());
|
||||
|
||||
Write("Enter a password: ");
|
||||
string? password = ReadLine(); // or "secretsauce"
|
||||
WriteLine("Is {0} a valid password? {1}",
|
||||
arg0: password, arg1: password.IsValidPassword());
|
||||
|
||||
Axis x = new("x", 0, 10, 1);
|
||||
Axis y = new("y", 0, 4, 1);
|
||||
Matrix<long> matrix = new(new[] { x, y });
|
||||
|
||||
for (int i = 0; i < matrix.Axes[0].Points.Length; i++)
|
||||
{
|
||||
matrix.Axes[0].Points[i].Label = "x" + i.ToString();
|
||||
}
|
||||
|
||||
for (int i = 0; i < matrix.Axes[1].Points.Length; i++)
|
||||
{
|
||||
matrix.Axes[1].Points[i].Label = "y" + i.ToString();
|
||||
}
|
||||
|
||||
foreach (long[] c in matrix)
|
||||
{
|
||||
matrix[c] = c[0] + c[1];
|
||||
}
|
||||
|
||||
foreach (long[] c in matrix)
|
||||
{
|
||||
WriteLine("{0},{1} ({2},{3}) = {4}",
|
||||
matrix.Axes[0].Points[c[0]].Label,
|
||||
matrix.Axes[1].Points[c[1]].Label,
|
||||
c[0], c[1], matrix[c]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue