title: Writing Ndef to NFC tag in Windows Form Application C# using ACR122U as Reader/Writer
body: <p>I am trying to create and write an NDEF message to an NFC tag in a Windows Form Application (written in C#) using an ACR122U NFC reader.</p>
  
  <p>I have created raw bytes of the NDEF message using Andreas Jakl's <a href="https://github.com/andijakl/ndef-nfc" rel="nofollow">NDEF library</a>. This is the C# code:</p>
  
  <pre><code>var spRecord = new NdefTextRecord {
                      Text = "1",
                      LanguageCode = "en"
                  };
  
  var msg = new NdefMessage { spRecord };
  
  string hex = BitConverter.ToString(msg.ToByteArray());
  
  resultBox.Text = hex.Replace('-',' ');
  </code></pre>
  
  <p>The output I get is <strong>D1 01 04 54 02 65 6E 31</strong> (hexadecimal).</p>
  
  <p>Then I'm writing this data to an NFC tag (MIFARE Ultralight) starting at block #5 using the following APDU commands:</p>
  
  <pre><code>CL INS P1 P2 Lc     DATA IN
  FF D6  00 05 04     D1 01 04 54
  
  CL INS P1 P2 Lc     DATA IN
  FF D6  00 05 04     02 65 6E 31
  </code></pre>
  
  <p>But when I try to read that tag using Android, the written NDEF message is not recognized.</p>
  
  <p>What do I need to do in order to get the NDEF message recognized by Android?</p>
  
  <blockquote>
    <p><strong><em>Solution (Thanks Michael Roland)</em></strong></p>
  </blockquote>
  
  <p>I wrote an NDEF tag using an Android app and then compared the values I have generated on that tag with the tag I wrote using the above method. The difference was 0x03 0x08 at the start. So 0x03 is a starting byte that is required and 0x08 is the length of the NDEF message. </p>
  
  <pre><code>FF D6 00 04 04   03 08 D1 01
  FF D6 00 05 04   04 54 02 65
  FF D6 00 06 04   6E 31 FE 00
  </code></pre>