Commit 28ea07e7 authored by Uwe Wienkop's avatar Uwe Wienkop

Einführung in die Zeichenketten

parent ecf9f4c5
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BCEB94CF-A8DE-4E6B-95EE-360E3933825D}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>_05Character</RootNamespace>
<AssemblyName>05Character</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _05Character
{
class Program
{
static void Main(string[] args)
{
string s = "Hallo Welt";
foreach (char c in s)
{
int x = c;
Console.WriteLine($"{c} | {x}");
}
Console.WriteLine("---------------");
for (int i = 0; i < s.Length; i++)
{
int x = s[i]; // i-tes Zeichen der Zeichenkette s
Console.WriteLine($"{s[i]} | {x}");
}
Console.WriteLine("---------------");
for (int i = 32; i < 128; i++)
{
//char c = (char) i;
Console.Write((char) i);
}
Console.WriteLine();
Console.WriteLine("---------------");
string s1 = "Hallo Welt";
Console.WriteLine(ToUpper(s1));
//if (s1 < s2)
}
static int CompareTo(string s1, string s2)
// 0 --> s1 == s2
// >0 --> s1 > s2
// <0 --> s1 < s2
{
int minZeichen; // Länge der kürzeren Zeichenkette bestimmen
if (s1.Length < s2.Length)
minZeichen = s1.Length;
else
minZeichen = s2.Length;
for (int i = 0; i < minZeichen; i++) // Vergleich solange beide Zeichenketten
{ // noch Zeichen enthalten
int diff = s1[i] - s2[i];
if (diff != 0)
return diff;
}
if (s1.Length == s2.Length) // Beide Zeichenketten gleich lang?
return 0; // 0 --> s1 == s2
else if (s1.Length > s2.Length) // Ist die erste Zeichenkette länger?
return 1; // pos.Erg --> s1 > s2
else
return -1; // neg.Erg --> s1 < s2
}
static string ToUpper(string s)
{
string sErg = "";
foreach (char c in s)
{
if (c >= 'a' && c <= 'z')
sErg += (char) (c - 32); // (char) unbedingt notwendig, sonst
else // werden die Zahlenwerte gespeichert
sErg += c;
}
return sErg;
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("05Character")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("05Character")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("bceb94cf-a8de-4e6b-95ee-360e3933825d")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
......@@ -40,6 +40,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "04Zufallszahlen", "04Zufall
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "04Praktikumstipps", "04Praktikumstipps\04Praktikumstipps.csproj", "{F89BDA2D-E54D-465B-A8F6-F60635BF6226}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "05Character", "05Character\05Character.csproj", "{BCEB94CF-A8DE-4E6B-95EE-360E3933825D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -110,6 +112,10 @@ Global
{F89BDA2D-E54D-465B-A8F6-F60635BF6226}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F89BDA2D-E54D-465B-A8F6-F60635BF6226}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F89BDA2D-E54D-465B-A8F6-F60635BF6226}.Release|Any CPU.Build.0 = Release|Any CPU
{BCEB94CF-A8DE-4E6B-95EE-360E3933825D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BCEB94CF-A8DE-4E6B-95EE-360E3933825D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCEB94CF-A8DE-4E6B-95EE-360E3933825D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BCEB94CF-A8DE-4E6B-95EE-360E3933825D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
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