Skip to content

Commit 8cc17b8

Browse files
committed
Fixed sample code and added using statements
1 parent 6d41db5 commit 8cc17b8

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

QRCoder/Assets/nuget-readme.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ The release notes for the current and all past releases can be read here: [📄
1919
You only need a couple lines of code, to generate your first QR code.
2020

2121
```csharp
22-
QRCodeGenerator qrGenerator = new QRCodeGenerator();
23-
QRCodeData qrCodeData = qrGenerator.CreateQrCode("The text which should be encoded.", QRCodeGenerator.ECCLevel.Q);
24-
QRCode qrCode = new PngByteQRCode(qrCodeData);
25-
byte[] qrCodeImage = qrCode.GetGraphic(20);
22+
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
23+
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode("The text which should be encoded.", QRCodeGenerator.ECCLevel.Q))
24+
using (PngByteQRCode qrCode = new PngByteQRCode(qrCodeData))
25+
{
26+
byte[] qrCodeImage = qrCode.GetGraphic(20);
27+
}
2628
```
2729

2830
There are a plenty of other options. So feel free to read more on that in our wiki: [Wiki: How to use QRCoder](https://github.com/codebude/QRCoder/wiki/How-to-use-QRCoder)

readme.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ _(More information on how to use Github Packages in Nuget Package Manager can be
4343
You only need a couple lines of code, to generate your first QR code.
4444

4545
```csharp
46-
QRCodeGenerator qrGenerator = new QRCodeGenerator();
47-
QRCodeData qrCodeData = qrGenerator.CreateQrCode("The text which should be encoded.", QRCodeGenerator.ECCLevel.Q);
48-
QRCode qrCode = new PngByteQRCode(qrCodeData);
49-
byte[] qrCodeImage = qrCode.GetGraphic(20);
46+
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
47+
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode("The text which should be encoded.", QRCodeGenerator.ECCLevel.Q))
48+
using (PngByteQRCode qrCode = new PngByteQRCode(qrCodeData))
49+
{
50+
byte[] qrCodeImage = qrCode.GetGraphic(20);
51+
}
5052
```
5153

5254
There are a plenty of other options. So feel free to read more on that in our wiki: [Wiki: How to use QRCoder](https://github.com/codebude/QRCoder/wiki/How-to-use-QRCoder)

0 commit comments

Comments
 (0)