added LINQ
This commit is contained in:
parent
40d3601e7f
commit
c59f7fe309
Binary file not shown.
BIN
20240911/ConsoleApp1/.vs/ConsoleApp1/v17/.suo
Normal file
BIN
20240911/ConsoleApp1/.vs/ConsoleApp1/v17/.suo
Normal file
Binary file not shown.
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"Version": 1,
|
||||||
|
"WorkspaceRootPath": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20240911\\ConsoleApp1\\",
|
||||||
|
"Documents": [
|
||||||
|
{
|
||||||
|
"AbsoluteMoniker": "D:0:0:{739297EA-E8FF-4D27-9F53-10E374FBB642}|ConsoleApp1\\ConsoleApp1.csproj|c:\\users\\szabomarton\\desktop\\c#\\progaora\\20240911\\consoleapp1\\consoleapp1\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||||
|
"RelativeMoniker": "D:0:0:{739297EA-E8FF-4D27-9F53-10E374FBB642}|ConsoleApp1\\ConsoleApp1.csproj|solutionrelative:consoleapp1\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"DocumentGroupContainers": [
|
||||||
|
{
|
||||||
|
"Orientation": 0,
|
||||||
|
"VerticalTabListWidth": 256,
|
||||||
|
"DocumentGroups": [
|
||||||
|
{
|
||||||
|
"DockedWidth": 200,
|
||||||
|
"SelectedChildIndex": 0,
|
||||||
|
"Children": [
|
||||||
|
{
|
||||||
|
"$type": "Document",
|
||||||
|
"DocumentIndex": 0,
|
||||||
|
"Title": "Program.cs",
|
||||||
|
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20240911\\ConsoleApp1\\ConsoleApp1\\Program.cs",
|
||||||
|
"RelativeDocumentMoniker": "ConsoleApp1\\Program.cs",
|
||||||
|
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20240911\\ConsoleApp1\\ConsoleApp1\\Program.cs",
|
||||||
|
"RelativeToolTip": "ConsoleApp1\\Program.cs",
|
||||||
|
"ViewState": "AgIAAAMAAAAAAAAAAAAQwBwAAAAoAAAAAAAAAA==",
|
||||||
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
|
"WhenOpened": "2024-09-11T10:02:46.053Z",
|
||||||
|
"EditorCaption": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
37
20240911/ConsoleApp1/.vs/ConsoleApp1/v17/DocumentLayout.json
Normal file
37
20240911/ConsoleApp1/.vs/ConsoleApp1/v17/DocumentLayout.json
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"Version": 1,
|
||||||
|
"WorkspaceRootPath": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20240911\\ConsoleApp1\\",
|
||||||
|
"Documents": [
|
||||||
|
{
|
||||||
|
"AbsoluteMoniker": "D:0:0:{739297EA-E8FF-4D27-9F53-10E374FBB642}|ConsoleApp1\\ConsoleApp1.csproj|c:\\users\\szabomarton\\desktop\\c#\\progaora\\20240911\\consoleapp1\\consoleapp1\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||||
|
"RelativeMoniker": "D:0:0:{739297EA-E8FF-4D27-9F53-10E374FBB642}|ConsoleApp1\\ConsoleApp1.csproj|solutionrelative:consoleapp1\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"DocumentGroupContainers": [
|
||||||
|
{
|
||||||
|
"Orientation": 0,
|
||||||
|
"VerticalTabListWidth": 256,
|
||||||
|
"DocumentGroups": [
|
||||||
|
{
|
||||||
|
"DockedWidth": 200,
|
||||||
|
"SelectedChildIndex": 0,
|
||||||
|
"Children": [
|
||||||
|
{
|
||||||
|
"$type": "Document",
|
||||||
|
"DocumentIndex": 0,
|
||||||
|
"Title": "Program.cs",
|
||||||
|
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20240911\\ConsoleApp1\\ConsoleApp1\\Program.cs",
|
||||||
|
"RelativeDocumentMoniker": "ConsoleApp1\\Program.cs",
|
||||||
|
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20240911\\ConsoleApp1\\ConsoleApp1\\Program.cs",
|
||||||
|
"RelativeToolTip": "ConsoleApp1\\Program.cs",
|
||||||
|
"ViewState": "AgIAABQAAAAAAAAAAAAgwC4AAAAoAAAAAAAAAA==",
|
||||||
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
|
"WhenOpened": "2024-09-11T10:02:46.053Z",
|
||||||
|
"EditorCaption": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
25
20240911/ConsoleApp1/ConsoleApp1.sln
Normal file
25
20240911/ConsoleApp1/ConsoleApp1.sln
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.11.35222.181
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{739297EA-E8FF-4D27-9F53-10E374FBB642}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{739297EA-E8FF-4D27-9F53-10E374FBB642}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{739297EA-E8FF-4D27-9F53-10E374FBB642}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{739297EA-E8FF-4D27-9F53-10E374FBB642}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{739297EA-E8FF-4D27-9F53-10E374FBB642}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {29E8667C-5B9B-4D3B-A1A8-1E156BF6070B}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
6
20240911/ConsoleApp1/ConsoleApp1/App.config
Normal file
6
20240911/ConsoleApp1/ConsoleApp1/App.config
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
53
20240911/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj
Normal file
53
20240911/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" 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>{739297EA-E8FF-4D27-9F53-10E374FBB642}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>ConsoleApp1</RootNamespace>
|
||||||
|
<AssemblyName>ConsoleApp1</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</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" />
|
||||||
|
</Project>
|
72
20240911/ConsoleApp1/ConsoleApp1/Program.cs
Normal file
72
20240911/ConsoleApp1/ConsoleApp1/Program.cs
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ConsoleApp1
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
struct Koordinatak
|
||||||
|
{
|
||||||
|
public int X { get; set; }
|
||||||
|
public int Y { get; set; }
|
||||||
|
}
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
//Pelda1();
|
||||||
|
Pelda2();
|
||||||
|
|
||||||
|
Console.ReadLine();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Pelda2()
|
||||||
|
{
|
||||||
|
var elemek = new List<Koordinatak>
|
||||||
|
{
|
||||||
|
new Koordinatak { X = 1, Y = 2 },
|
||||||
|
new Koordinatak { X = 2, Y = 3 },
|
||||||
|
new Koordinatak { X = 5, Y = 3 },
|
||||||
|
new Koordinatak { X = 6, Y = 3 },
|
||||||
|
new Koordinatak { X = 10, Y = 0 },
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var eredmeny = from elem in elemek select elem.X;
|
||||||
|
var eredmeny2 = elemek.Select(item => item.X);
|
||||||
|
foreach (var item in eredmeny)
|
||||||
|
{
|
||||||
|
Console.WriteLine(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in eredmeny2)
|
||||||
|
{
|
||||||
|
Console.WriteLine(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void Pelda1()
|
||||||
|
{
|
||||||
|
int[] szamok = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||||
|
|
||||||
|
|
||||||
|
var eredmeny = from szam in szamok
|
||||||
|
where (szam % 2) == 0
|
||||||
|
select szam;
|
||||||
|
|
||||||
|
var eredmeny2 = szamok.Where(szam => szam % 2 == 0);
|
||||||
|
|
||||||
|
foreach (var item in eredmeny2)
|
||||||
|
{
|
||||||
|
Console.WriteLine(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in eredmeny)
|
||||||
|
{
|
||||||
|
Console.WriteLine(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
20240911/ConsoleApp1/ConsoleApp1/Properties/AssemblyInfo.cs
Normal file
33
20240911/ConsoleApp1/ConsoleApp1/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
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("ConsoleApp1")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("ConsoleApp1")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2024")]
|
||||||
|
[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("739297ea-e8ff-4d27-9f53-10e374fbb642")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
BIN
20240911/ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.exe
Normal file
BIN
20240911/ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.exe
Normal file
Binary file not shown.
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
BIN
20240911/ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.pdb
Normal file
BIN
20240911/ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.pdb
Normal file
Binary file not shown.
|
@ -0,0 +1,4 @@
|
||||||
|
// <autogenerated />
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
|
Binary file not shown.
|
@ -0,0 +1 @@
|
||||||
|
137ddb1975586287657f37337b64d051167bb6a147915d9fb5b8eb94b1093509
|
|
@ -0,0 +1,7 @@
|
||||||
|
C:\Users\szabomarton\Desktop\C#\ProgaOra\20240911\ConsoleApp1\ConsoleApp1\obj\Debug\ConsoleApp1.csproj.AssemblyReference.cache
|
||||||
|
C:\Users\szabomarton\Desktop\C#\ProgaOra\20240911\ConsoleApp1\ConsoleApp1\obj\Debug\ConsoleApp1.csproj.CoreCompileInputs.cache
|
||||||
|
C:\Users\szabomarton\Desktop\C#\ProgaOra\20240911\ConsoleApp1\ConsoleApp1\bin\Debug\ConsoleApp1.exe.config
|
||||||
|
C:\Users\szabomarton\Desktop\C#\ProgaOra\20240911\ConsoleApp1\ConsoleApp1\bin\Debug\ConsoleApp1.exe
|
||||||
|
C:\Users\szabomarton\Desktop\C#\ProgaOra\20240911\ConsoleApp1\ConsoleApp1\bin\Debug\ConsoleApp1.pdb
|
||||||
|
C:\Users\szabomarton\Desktop\C#\ProgaOra\20240911\ConsoleApp1\ConsoleApp1\obj\Debug\ConsoleApp1.exe
|
||||||
|
C:\Users\szabomarton\Desktop\C#\ProgaOra\20240911\ConsoleApp1\ConsoleApp1\obj\Debug\ConsoleApp1.pdb
|
BIN
20240911/ConsoleApp1/ConsoleApp1/obj/Debug/ConsoleApp1.exe
Normal file
BIN
20240911/ConsoleApp1/ConsoleApp1/obj/Debug/ConsoleApp1.exe
Normal file
Binary file not shown.
BIN
20240911/ConsoleApp1/ConsoleApp1/obj/Debug/ConsoleApp1.pdb
Normal file
BIN
20240911/ConsoleApp1/ConsoleApp1/obj/Debug/ConsoleApp1.pdb
Normal file
Binary file not shown.
Binary file not shown.
13
linq_anyag
Normal file
13
linq_anyag
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
A linq to objects az IEnumerable<T> és IEnumerable interfészeket megvalósító (foreach ciklussal bejárható) kollekció esetén működnek.
|
||||||
|
A megvalósítás a Syste.Linq névtérben kapott helyet, amit alapvetően nem kell használatba vennünk, mert ha egy új osztályt készítünk sablon alapján visual studioban akkor alapértelmezetten használatba lesz véve.
|
||||||
|
|
||||||
|
A linq szintaxisai:
|
||||||
|
Lambda:
|
||||||
|
elemek.Where(i => i.X > 10).Select(i => i.x);
|
||||||
|
querry:
|
||||||
|
var eredmeny = from elem in elemek
|
||||||
|
where elem.x > 10
|
||||||
|
select elem.x;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user