Commit 677e3bae authored by Uwe Wienkop's avatar Uwe Wienkop

2020-05-26c

parent 4c5cfaed
namespace HTML
{
// HTML engine for generation of a HTML string from an array of HTML tag elements:
{
// HTML engine for generation of a HTML string from an array of HTML tag elements:
public interface ITagged { string TagId { get; } } // Used to define HTML tag element
public interface ITagged { string TagId { get; } } // Used to define HTML tag element
public interface INested { object[] Elements { get; } } // Used to "mark" a HTML tag element as nested
public interface INested { object[] Elements { get; } } // Used to "mark" a HTML tag element as nested
class Body : ITagged, INested
{
public string TagId => "body";
public Body(params object[] Elements) { this.Elements = Elements; }
public object[] Elements { get; private set; }
}
public static class Engine
{
public static string Generate(params object[] elements)
public static class Engine
{
// TODO: Your code for (recursive) generation of a HTML string from array "elements" here...
public static string Generate(params object[] elements)
{
// TODO: Your code for (recursive) generation of a HTML string from array "elements" here...
}
}
}
}
\ No newline at end of file
......@@ -67,6 +67,7 @@ class Program
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo("Example.html");
startInfo.UseShellExecute = true;
System.Diagnostics.Process.Start(startInfo);
//System.Diagnostics.Process.Start("Example.html");
}
}
......@@ -42,9 +42,13 @@ namespace _06_UebgDiExceptions
try
{
Funktion3();
//Funktion3b();
//if (errno != 0)
// Console.WriteLine("In Funktion 3b ist ein Fehler passiert");
Console.WriteLine("Letzte Anweisung des try-Blocks von Funktion 2");
}
catch(MyAppExceptions e)
catch(MyAppExceptions e) // Fängt MyAppExceptions und alle Exceptions, die
// von MyAppExceptions abgeleitet sind
{
Console.WriteLine($"catch in Funktion 2: {e.Message}, {e.fehlerwert}");
throw;
......@@ -60,7 +64,8 @@ namespace _06_UebgDiExceptions
Console.WriteLine("Funktion3");
int x = 2;
if (1 < x)
throw new MyAppExceptions("Fehler in Funktion3", 4711);
throw new DivideByZeroException("Fehler in F3");
//throw new MyAppExceptions("Fehler in Funktion3", 4711);
Console.WriteLine("Ende von Funktion3");
}
static int errno=0;
......@@ -69,11 +74,25 @@ namespace _06_UebgDiExceptions
int x = 0;
errno = 9999;
int y = 3 / x;
}
static void Main(string[] args)
{
Funktion1();
bool fehler;
do
{
// Init ...
try
{
fehler = false;
Funktion1();
}
catch (Exception)
{
Console.WriteLine("Allgemeiner Fehler");
fehler = true;
// Neuinitialisierung ...
}
} while (fehler == true);
}
}
}
......@@ -10,14 +10,14 @@ namespace _06Exceptions_Threads
// The method that will be called when the thread is started.
public void InstanceMethod()
{
int data = count++;
int processNr = count++;
try
{
Console.WriteLine(" InstanceMethod läuft in einem eigenen Thread");
// Pause for a moment to provide a delay to make
// threads more apparent.
if (data == 3)
if (processNr == 3)
{
Thread.Sleep(2000);
throw new NullReferenceException("Null Referenz!!!");
......@@ -27,11 +27,11 @@ namespace _06Exceptions_Threads
}
catch (Exception e)
{
Console.WriteLine($"!!!Fehler {e.Message} in Instanz {data}");
Console.WriteLine($"!!!Fehler {e.Message} in Instanz {processNr}");
}
finally
{
Console.WriteLine($" Thread {data} wurde beendet");
Console.WriteLine($" Thread {processNr} wurde beendet");
}
}
}
......
......@@ -10,3 +10,4 @@ C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\06Exceptions_Threads\obj\Debu
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\06Exceptions_Threads\obj\Debug\netcoreapp3.1\06Exceptions_Threads.dll
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\06Exceptions_Threads\obj\Debug\netcoreapp3.1\06Exceptions_Threads.pdb
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\06Exceptions_Threads\obj\Debug\netcoreapp3.1\06Exceptions_Threads.genruntimeconfig.cache
C:\Users\wienkop\source\repos\prog2-ss2020-wienkop\06Exceptions_Threads\obj\Debug\netcoreapp3.1\06Exceptions_Threads.csprojAssemblyReference.cache
......@@ -31,10 +31,16 @@ namespace _06WPF_Ausnahmen
{
int a = Convert.ToInt32(tb1.Text);
int b = Convert.ToInt32(tb2.Text);
if (b > 1000)
throw new ArgumentException("Wert zu groß bei Eingabe 2");
int c = Convert.ToInt32(tb3.Text);
int d = Convert.ToInt32(tb4.Text);
ErgLbl.Content = a + b + c + d;
}
catch (FormatException)
{
MessageBox.Show("Vermutlich eine falsche Eingabe. Bitte prüfen Sie die Textboxen");
}
catch (Exception ex)
{
MessageBox.Show("Fehler bei der Eingabe " + ex.Message);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment