SlideShare a Scribd company logo
1 of 32
Download to read offline
C#画像処理講習
ー第1回ー
K.Miyauchi
2021.12.07
目次
・C#とは
・講習の進め方
・開発環境準備
・コンソールアプリケーション
・コンソール出力
・コンソール入力
・変数
・基本的な文法
(c) K.Miyauchi 2
本講習で使用するもの
パソコン:Windows, Mac
開発環境:Visual Studio 2022 Community
(c) K.Miyauchi 3
C#とは
Microsoftが開発したオブジェクト指向型プログラミング言語である.
C#という名がついているが,
C言語やC++とは互換性がないので注意が必要である.
※文法は似ているが,Javaの方が似ている.
XamarinやUnityをC#に組み込むことによって,
AndroidやiOSのクロスプラットフォーム開発や
3Dゲーム等の開発を行うことができる.
また,Microsoftが開発している言語ということもあり,
Windows系のアプリケーションに開発することに特化している.
(c) K.Miyauchi 4
講習の進め方
前述したように,C#は,C言語と文法がとても似ています.
基本的な文法などについては,
説明が省かれているところがあります.
また,文法が異なるところでも,
説明があるところとないところがあったりします.
演習では,説明がされていない部分を用いる可能性もあります(極
力そのようにならないようにします).
演習でプログラムを作成していて,ステートメントエラーがでたとき
には,文法を疑ってください.
(c) K.Miyauchi 5
講習の進め方
「C# ○○」のように,
Googleなどで検索することで記事はたくさん出てきます.
プログラムの開発スピードを上げることで重要なのは,
検索力をつけることです.
本講習を通して,検索力を身につけてください.
また,○○のプロフェッショナルみたいな人が,
「これは,調べればすぐでてくるから覚えていない」
とか言っている人がいますが,これはウソです.
検索に必要な最低限なキーワードは覚えています.
最低限な部分はしっかりと覚えていきましょう.
(c) K.Miyauchi 6
開発環境準備
開発環境には,Visual Studio 2022 Communityを使用する.
(c) K.Miyauchi 7
Visual Studio 2022 download
で検索
「Visual Studio Toolのダウンロード」
をクリック
開発環境準備
(c) K.Miyauchi 8
インストーラをダウンロード
コミュニティを
無料ダウンロード
開発環境準備
ダウンロード待ち
(c) K.Miyauchi 9
ダウンロードした
ものを開く
ダウンロードが始まらな
い場合にはクリック
開発環境準備
プライバシー,ライセンス条項の同意
(c) K.Miyauchi 10
クリック
開発環境準備
.NETデスクトップ開発のみインストール
(c) K.Miyauchi 11
インストール
.NET デスクトップ開発
にチェック
開発環境準備
インストールが終了するまで待機
(c) K.Miyauchi 12
開発環境準備
スタートメニューからVisual Studio 2022をクリックして起動.
起動時にテーマの選択がある場合は,適当なのを選択して進む.
このような画面が出ればOK.
(c) K.Miyauchi 13
コンソールアプリケーション
コンソールアプリケーションとは,
CUIベースのアプリケーションである.
(c) K.Miyauchi 14
新しいプロジェクトの作成
をクリック
コンソールアプリケーション
コンソールアプリを選択
(c) K.Miyauchi 15
コンソールアプリ
を選択
次へ
をクリック
コンソールアプリケーション
プロジェクトの作成
(c) K.Miyauchi 16
プロジェクト名を
適当に入力
※ソースコードのグループ名
次へ
をクリック
ソリューション名を
適当に入力
※プロジェクトのグループ名
コンソールアプリケーション
プロジェクトの設定
(c) K.Miyauchi 17
最新バージョンか
確認
作成
をクリック
コンソールアプリケーション
このような画面が出ればOK
(c) K.Miyauchi 18
コンソールアプリケーション
このような画面が出ればOK
(c) K.Miyauchi 19
「▶」をクリック
コンソール出力
プログラムを以下のように変更
(c) K.Miyauchi 20
いっときの間は,Mainの中身
だけを変更していく.
コンソール出力
コンソールで文字出力をしてみましょう.
(c) K.Miyauchi 21
Writeは,
“”で囲まれた文字を改行
なしで出力する.
WriteLineは,
“”で囲まれた文字を改行
で出力する.
Enviroment.NewLineは,
マシンに適した改行コー
ドを挿入する.
¥r¥nは,Windowsマシン
の改行コード.
コンソール入力
プログラムの内容が変わるので,
ソリューションにプロジェクトを追加します.
(c) K.Miyauchi 22
新しいプロジェクト
をクリック
コンソール入力
コンソールで文字入力をしてみましょう.
(c) K.Miyauchi 23
ReadLineは,
改行されるまでの文字を
入力として受け取る
Readは,
1文字を入力として受け
取る.(int型で返される)
(char)を書くことによって,
キャストをcharにする.
変数
変数とは,データを入れておくことのできる箱みたいなものである.
自由に,好きな時にデータの読み書きをすることができる.
(c) K.Miyauchi 24
123
Hello
World
0.124
変数
変数によって,
扱うことのできるデータの種類が変わる.
(整数,実数,文字,文字列...etc.)
扱うことのできるデータの種類のことを「型」という.
また,C#は変数を使用する際には,
「宣言」をする必要がある.
宣言の書き方は,以下の通りである(C/C++と同じ).
変数型 変数名;
(c) K.Miyauchi 25
変数
変数名には,使えない文字が存在するので注意.
また,変数名の先頭には数字を使用することは不可.
使用できない文字を使用しているときには,
プログラムの実行時にエラーが出るので,
エラーが出たときに,使えない文字と認識するのでOK.
(c) K.Miyauchi 26
変数
数値を扱うことのできる変数型として,以下のものがある.
(c) K.Miyauchi 27
変数型名 扱える種類 データサイズ[bit] 扱える範囲
sbyte 整数 8 −128 ~ 127
short 整数 16 −215
~215
− 1
int 整数 32 −231~231 − 1
long 整数 64 −263~263 − 1
float 実数 32
±1.5 × 10−45
~
± 3.4 × 1038
double 実数 64
±5.0 × 10−324~
± 1.7 × 10308
decimal 実数 128
±1.0 × 10−28
~
± 7.9 × 1028
変数
変数の入力や出力は,以下のような書き方で行うことができる.
(c) K.Miyauchi 28
ReadLine()は,
string型(文字列型)で入力
文字が返される.
WriteLine(変数)で,変数の
中身を表示する.
一定の文字列と変数を組み
合わせたものを表示する.
C/C++のprintfのような記法
一定の文字列と変数を組み合わせた
ものを表示する.
上記とは違い,組み込むような記法
基本的な文法
if-else, for, whileなどの基本的な制御については,C/C++と文法は同
じである.
(c) K.Miyauchi 29
if (/*条件式*/)
{
// 条件式がtrueのときの処理
}
else
{
// 条件式がfalseのときの処理
}
基本的な文法
(c) K.Miyauchi 30
switch (/*変数*/)
{
case 0:
// 変数=0のときの処理
break;
case 1:
// 変数=1のときの処理
break;
default:
// どのcaseにも当てはまらない時の処理
break;
}
基本的な文法
(c) K.Miyauchi 31
while (/*条件式*/)// 処理前に条件式を確認する
{
// 条件式が成立する間の処理
}
do
{
// 条件式が成立する間の処理
}while(/*条件式*/);//処理後に条件式を確認する
for(/*処理1*/; /*条件式*/; /*処理3*/ )
{
// 処理2
}
処理1⇒条件式⇒処理2⇒
処理3⇒条件式⇒処理2⇒…
と処理されていく.
演習
・二次方程式𝑎𝑥2 + 𝑏𝑥 + 𝑐 = 0の係数𝑎 ≠ 0 , 𝑏, 𝑐を入力して解を
求めるプログラムを作成せよ.ただし,重解のときは解は1つのみ
表示するものとする.
・ループ処理を使用し,九九表を作成せよ.
・一つの整数を入力し,その整数が素数であるかを判定するプログ
ラムを作成せよ.
(c) K.Miyauchi 32

More Related Content

Similar to 第1回c#画像処理講習

C# programming language
C# programming languageC# programming language
C# programming languageswarnapatil
 
TechnoGeek training report
TechnoGeek training reportTechnoGeek training report
TechnoGeek training reportAnup Singh
 
C c training in chennai what is in store
C c training in chennai what is in storeC c training in chennai what is in store
C c training in chennai what is in storehbservicess
 
DotNet Fundamentals
DotNet FundamentalsDotNet Fundamentals
DotNet FundamentalsMajdi SAIBI
 
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Xamarin
 
Chapter-1 C#.pptx
Chapter-1 C#.pptxChapter-1 C#.pptx
Chapter-1 C#.pptxfaarax4
 
programming in c#.ppt
programming in c#.pptprogramming in c#.ppt
programming in c#.pptNalinaKumari2
 
Event Driven Programming in C#.docx
Event Driven Programming in C#.docxEvent Driven Programming in C#.docx
Event Driven Programming in C#.docxLenchoMamudeBaro
 
All You Need To Know About C Program Assignment Help.pdf
All You Need To Know About C Program Assignment Help.pdfAll You Need To Know About C Program Assignment Help.pdf
All You Need To Know About C Program Assignment Help.pdfBrad Smith
 
Visual Studio for Mac (AltConf 2017)
Visual Studio for Mac (AltConf 2017)Visual Studio for Mac (AltConf 2017)
Visual Studio for Mac (AltConf 2017)Craig Dunn
 
Summer training PPT Manasv Singharia.pptx
Summer training PPT Manasv Singharia.pptxSummer training PPT Manasv Singharia.pptx
Summer training PPT Manasv Singharia.pptxshokeenk14
 
AnDevCon - Android and iOS Apps in C# with Xamarin
AnDevCon - Android and iOS Apps in C# with XamarinAnDevCon - Android and iOS Apps in C# with Xamarin
AnDevCon - Android and iOS Apps in C# with XamarinJames Montemagno
 

Similar to 第1回c#画像処理講習 (20)

C#
C#C#
C#
 
C# programming language
C# programming languageC# programming language
C# programming language
 
TechnoGeek training report
TechnoGeek training reportTechnoGeek training report
TechnoGeek training report
 
Programming with c#
Programming with c#Programming with c#
Programming with c#
 
Programming in c#
Programming in c#Programming in c#
Programming in c#
 
Presentation1
Presentation1Presentation1
Presentation1
 
C# handout.docx
C# handout.docxC# handout.docx
C# handout.docx
 
C c training in chennai what is in store
C c training in chennai what is in storeC c training in chennai what is in store
C c training in chennai what is in store
 
DotNet Fundamentals
DotNet FundamentalsDotNet Fundamentals
DotNet Fundamentals
 
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
 
Chapter-1 C#.pptx
Chapter-1 C#.pptxChapter-1 C#.pptx
Chapter-1 C#.pptx
 
programming in c#.ppt
programming in c#.pptprogramming in c#.ppt
programming in c#.ppt
 
C#.ppt
C#.pptC#.ppt
C#.ppt
 
Event Driven Programming in C#.docx
Event Driven Programming in C#.docxEvent Driven Programming in C#.docx
Event Driven Programming in C#.docx
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
C#
C#C#
C#
 
All You Need To Know About C Program Assignment Help.pdf
All You Need To Know About C Program Assignment Help.pdfAll You Need To Know About C Program Assignment Help.pdf
All You Need To Know About C Program Assignment Help.pdf
 
Visual Studio for Mac (AltConf 2017)
Visual Studio for Mac (AltConf 2017)Visual Studio for Mac (AltConf 2017)
Visual Studio for Mac (AltConf 2017)
 
Summer training PPT Manasv Singharia.pptx
Summer training PPT Manasv Singharia.pptxSummer training PPT Manasv Singharia.pptx
Summer training PPT Manasv Singharia.pptx
 
AnDevCon - Android and iOS Apps in C# with Xamarin
AnDevCon - Android and iOS Apps in C# with XamarinAnDevCon - Android and iOS Apps in C# with Xamarin
AnDevCon - Android and iOS Apps in C# with Xamarin
 

More from Koshiro Miyauchi

More from Koshiro Miyauchi (8)

第2回c#画像処理講習
第2回c#画像処理講習第2回c#画像処理講習
第2回c#画像処理講習
 
第7回電子制御講習
第7回電子制御講習第7回電子制御講習
第7回電子制御講習
 
第6回電子制御講習
第6回電子制御講習第6回電子制御講習
第6回電子制御講習
 
第5回電子制御講習
第5回電子制御講習第5回電子制御講習
第5回電子制御講習
 
第4回電子制御講習
第4回電子制御講習第4回電子制御講習
第4回電子制御講習
 
第3回電子制御講習
第3回電子制御講習第3回電子制御講習
第3回電子制御講習
 
第2回電子制御講習
第2回電子制御講習第2回電子制御講習
第2回電子制御講習
 
第1回電子制御講習
第1回電子制御講習第1回電子制御講習
第1回電子制御講習
 

Recently uploaded

Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseWSO2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaWSO2
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuidePixlogix Infotech
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringWSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 

Recently uploaded (20)

Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

第1回c#画像処理講習