Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net10.0</TargetFramework>
Comment thread
gewarren marked this conversation as resolved.
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void Main()
// C:\Program Files\
// </Snippet2>

public class FileUtilities
public class FileUtilities1
{
internal static string AppendDirectorySeparator(string dir)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// <Snippet6>
using System;

public class Example1
{
public static void Main()
{
String s = "The Sign of the Four";
//Console.WriteLine(Utilities.StringUtilities.StringLib.IsFirstLetterUpperCase(s));
}
}
// </Snippet6>
Comment thread
gewarren marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Runtime.CompilerServices;

// <Snippet3>
[assembly:InternalsVisibleTo("Friend1a")]
[assembly:InternalsVisibleTo("Friend1b")]
// </Snippet3>

public class StringUtilities
{
internal string ToTitleCase(string value)
{
string retval = null;
for (int ctr = 0; ctr < value.Length; ctr++)
if (ctr == 0)
retval += Char.ToUpper(value[ctr]);
else if (ctr > 0 && Char.IsWhiteSpace(value[ctr - 1]))
retval += Char.ToUpper(value[ctr]);
else
retval += value[ctr];
return retval;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Runtime.CompilerServices;

// <Snippet4>
[assembly:InternalsVisibleTo("Friend2a"),
InternalsVisibleTo("Friend2b")]
// </Snippet4>

namespace Utilities
{
public class StringUtilities1
{
internal static string ToTitleCase(string value)
{
string retval = null;
for (int ctr = 0; ctr < value.Length; ctr++)
if (ctr == 0)
retval += Char.ToUpper(value[ctr]);
else if (ctr > 0 && Char.IsWhiteSpace(value[ctr - 1]))
retval += Char.ToUpper(value[ctr]);
else
retval += value[ctr];
return retval;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// <Snippet1>
using System;
using System.Runtime.CompilerServices;

public class Example
{
public static void Main()
{
Console.WriteLine("{0,-18} {1,6} {2,18:N0} {3,6} {4,18:N0}\n",
"", "Var 1", "Hash Code", "Var 2", "Hash Code");

// Get hash codes of two different strings.
String sc1 = "String #1";
String sc2 = "String #2";
ShowHashCodes("sc1", sc1, "sc2", sc2);

// Get hash codes of two identical non-interned strings.
String s1 = "This string";
String s2 = String.Format("{0} {1}", "This", "string");
ShowHashCodes("s1", s1, "s2", s2);

// Get hash codes of two (evidently concatenated) strings.
String si1 = "This is a string!";
String si2 = "This " + "is " + "a " + "string!";
ShowHashCodes("si1", si1, "si2", si2);
}

private static void ShowHashCodes(String var1, Object value1,
String var2, Object value2)
{
Console.WriteLine("{0,-18} {1,6} {2,18:X8} {3,6} {4,18:X8}",
"Obj.GetHashCode", var1, value1.GetHashCode(),
var2, value2.GetHashCode());

Console.WriteLine("{0,-18} {1,6} {2,18:X8} {3,6} {4,18:X8}\n",
"RTH.GetHashCode", var1, RuntimeHelpers.GetHashCode(value1),
var2, RuntimeHelpers.GetHashCode(value2));
}
}
// The example displays output similar to the following:
// Var 1 Hash Code Var 2 Hash Code
//
// Obj.GetHashCode sc1 94EABD27 sc2 94EABD24
// RTH.GetHashCode sc1 02BF8098 sc2 00BB8560
//
// Obj.GetHashCode s1 29C5A397 s2 29C5A397
// RTH.GetHashCode s1 0297B065 s2 03553390
//
// Obj.GetHashCode si1 941BCEA5 si2 941BCEA5
// RTH.GetHashCode si1 01FED012 si2 01FED012
// </Snippet1>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
// <Snippet4>
using System.Runtime.InteropServices;
// </Snippet4>

// <Snippet1>
public interface INew
{
void NewMethod();
}
// </Snippet1>

// <Snippet2>
public interface ICustomMarshaler
{
Object MarshalNativeToManaged(IntPtr pNativeData);
IntPtr MarshalManagedToNative(Object ManagedObj);
void CleanUpNativeData(IntPtr pNativeData);
void CleanUpManagedData(Object ManagedObj);
int GetNativeDataSize();
}
// </Snippet2>

namespace scope1
{
// <Snippet3>
interface IUserData
{
void DoSomeStuff(INew pINew);
}
// </Snippet3>
}

namespace scope2
{
// <Snippet5>
interface IUserData
{
void DoSomeStuff(
[MarshalAs(UnmanagedType.CustomMarshaler,
MarshalType="NewOldMarshaler")]
INew pINew
);
}
// </Snippet5>
}

// <Snippet6>
public class NewOldMarshaler : ICustomMarshaler
{
public static ICustomMarshaler GetInstance(string pstrCookie)
=> new NewOldMarshaler();

public Object MarshalNativeToManaged(IntPtr pNativeData) => throw new NotImplementedException();
public IntPtr MarshalManagedToNative(Object ManagedObj) => throw new NotImplementedException();
public void CleanUpNativeData(IntPtr pNativeData) => throw new NotImplementedException();
public void CleanUpManagedData(Object ManagedObj) => throw new NotImplementedException();
public int GetNativeDataSize() => throw new NotImplementedException();
}
// </Snippet6>

class StubClass
{
public static void Main() { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ Imports System.IO
Module Example
Public Sub Main()
Dim dir As String = "C:\Program Files"
dir = FileUtilities.AppendDirectorySeparator(dir)
Console.WriteLine(dir)
dir = FileUtilities1.AppendDirectorySeparator(dir)
Console.WriteLine(dir)
End Sub
End Module
' The example displays the following output:
' C:\Program Files\
' </Snippet2>


Public Class FileUtilities
Friend Shared Function AppendDirectorySeparator(dir As String) As String
If Not dir.Trim().EndsWith(Path.DirectorySeparatorChar) Then
Return dir.Trim() + Path.DirectorySeparatorChar
Else
Return dir
End If
End Function
Public Class FileUtilities1
Friend Shared Function AppendDirectorySeparator(dir As String) As String
If Not dir.Trim().EndsWith(Path.DirectorySeparatorChar) Then
Return dir.Trim() + Path.DirectorySeparatorChar
Else
Return dir
End If
End Function
End Class
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
' Visual Basic .NET Document
Option Strict On

' <Snippet6>
Module Example1
Public Sub Main()
Dim s As String = "The Sign of the Four"
' Console.WriteLine(Utilities.StringUtilities.StringLib.IsFirstLetterUpperCase(s))
End Sub
Comment thread
gewarren marked this conversation as resolved.
End Module
' </Snippet6>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Imports System.Runtime.CompilerServices

' <Snippet3>
<assembly:InternalsVisibleTo("Friend1a")>
<assembly:InternalsVisibleTo("Friend1b")>
' </Snippet3>
Public Class StringUtilities
Friend Function ToTitleCase(value As String) As String
Dim retval As String = Nothing
For ctr As Integer = 0 To value.Length - 1
If ctr = 0 Then
retval += Char.ToUpper(value(ctr))
ElseIf ctr > 0 AndAlso Char.IsWhiteSpace(value(ctr - 1))
retval += Char.ToUpper(value(ctr))
Else
retval += value(ctr)
End If
Next
Return retval
End Function
End Class
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Imports System.Runtime.CompilerServices

' <Snippet4>
<Assembly:InternalsVisibleTo("Friend2a"), _
Assembly:InternalsVisibleTo("Friend2b")>
' </Snippet4>
Namespace Utilities
Public Class StringUtilities1
Friend Shared Function ToTitleCase(value As String) As String
Dim retval As String = Nothing
For ctr As Integer = 0 To value.Length - 1
If ctr = 0 Then
retval += Char.ToUpper(value(ctr))
ElseIf ctr > 0 AndAlso Char.IsWhiteSpace(value(ctr - 1)) Then
retval += Char.ToUpper(value(ctr))
Else
retval += value(ctr)
End If
Next
Return retval
End Function
End Class
End Namespace
File renamed without changes.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

</Project>
Loading
Loading