Skip to content
Snippets Groups Projects
Commit db12f716 authored by Vesa Lappalainen's avatar Vesa Lappalainen :bicyclist:
Browse files

luento11

parent f710101f
No related branches found
No related tags found
No related merge requests found
Showing with 76 additions and 7 deletions
......@@ -18,7 +18,7 @@ public class StringVsStringBuilder
public static void Main(string[] args)
{
// Yhdistellään merkkijonoja StringBuilder-olion avulla
const int MONTAKO = 50000; // Montako kertaa merkkijonoja yhdistellään
const int MONTAKO = 2*50000; // Montako kertaa merkkijonoja yhdistellään
Stopwatch sw = Stopwatch.StartNew();
StringBuilder sb = new StringBuilder("a");
for (int i = 0; i < MONTAKO; i++)
......@@ -69,5 +69,13 @@ public class StringVsStringBuilder
// Pituus 588891
// True
// Tulostus 2023, AMD Ryzen 9 5900X 12-Core Processor 3.70 GHz
// StringBuilder 0.004 s
// Pituus 588891
// SB Insert 10.201 s
// Pituus 588891
// String 8.836 s
// Pituus 588891
// True
}
}
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/.idea.luento10.iml
/projectSettingsUpdater.xml
/modules.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/.idea.luento11.iml
/modules.xml
/contentModel.xml
/projectSettingsUpdater.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/// @author Vesa Lappalainen
......@@ -43,17 +41,18 @@ public class Olioviitteet
// ==========================================================
String st1 = "eka";
String st2 = s1.ToString();
string st1 = "eka";
string st2 = s1.ToString();
Console.WriteLine(Object.ReferenceEquals(st1, st2)); // false
Console.WriteLine(st1 == st2); // true
Console.WriteLine(st1.Equals(st2)); // true
Console.WriteLine(object.ReferenceEquals(st1, st2)); // false
st2 = null;
Console.WriteLine(st2 == null); // true
Console.WriteLine(Object.ReferenceEquals(st1, st2)); // false
Console.WriteLine(object.ReferenceEquals(st1, st2)); // false
st1 = null;
Console.WriteLine(Object.ReferenceEquals(st1, st2)); // true
Console.WriteLine(object.ReferenceEquals(st1, st2)); // true
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment