<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GeoAvila (Geovanny G. Avila) &#187; C# Csharp Validar NIT Guatemala</title>
	<atom:link href="http://geoavila.com/tag/c-csharp-validar-nit-guatemala/feed/" rel="self" type="application/rss+xml" />
	<link>http://geoavila.com</link>
	<description>Desarrollo.. de software.</description>
	<lastBuildDate>Tue, 27 Apr 2010 23:30:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Validar un NIT(Guatemala) en C#</title>
		<link>http://geoavila.com/validar-un-nitguatemala-en-c/</link>
		<comments>http://geoavila.com/validar-un-nitguatemala-en-c/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 19:54:32 +0000</pubDate>
		<dc:creator>GeoAvila</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[C# Csharp Validar NIT Guatemala]]></category>

		<guid isPermaLink="false">http://geoavila.com/?p=232</guid>
		<description><![CDATA[


 Esta función,  encontre esta función para validar un NIT con JavaScript, bueno pasando a C#, quedaría algo así, espero les sirva el este código.
PLAIN TEXT
C#:




public bool ValidarNIT&#40;string Nit&#41;


&#160; &#160; &#160; &#160; &#123;


&#160; &#160; &#160; &#160; &#160; &#160; int pos = Nit.IndexOf&#40;"-"&#41;;


&#160; &#160; &#160; &#160; &#160; &#160; string Correlativo = Nit.Substring&#40;0, pos&#41;;


&#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-6058344163325637";
/* 468x15, creado 17/10/08 */
google_ad_slot = "2693427472";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></-> <p>Esta función,  encontre esta función para validar un <a href="http://leblogmca.blogspot.com/2008/02/validar-el-nit-con-modulo-11.html">NIT con JavaScript</a>, bueno pasando a C#, quedaría algo así, espero les sirva el este código.</p>
<div class="igBar"><span id="lcsharp-2"><a href="#" onclick="javascript:showPlainTxt('csharp-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-2">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">bool</span> ValidarNIT<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> Nit<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">int</span> pos = Nit.<span style="color: #0000FF;">IndexOf</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"-"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> Correlativo = Nit.<span style="color: #0000FF;">Substring</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">0</span>, pos<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> DigitoVerificador = Nit.<span style="color: #0000FF;">Substring</span><span style="color: #000000;">&#40;</span>pos + <span style="color: #FF0000;color:#800000;">1</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">int</span> Factor = Correlativo.<span style="color: #0000FF;">Length</span> + <span style="color: #FF0000;color:#800000;">1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">int</span> Suma = <span style="color: #FF0000;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">int</span> Valor = <span style="color: #FF0000;color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> x = <span style="color: #FF0000;color:#800000;">0</span>; x &lt;= Nit.<span style="color: #0000FF;">IndexOf</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"-"</span><span style="color: #000000;">&#41;</span> - <span style="color: #FF0000;color:#800000;">1</span>; x++<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Valor = Convert.<span style="color: #0000FF;">ToInt32</span><span style="color: #000000;">&#40;</span>Nit.<span style="color: #0000FF;">Substring</span><span style="color: #000000;">&#40;</span>x, <span style="color: #FF0000;color:#800000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Suma = Suma + <span style="color: #000000;">&#40;</span>Valor * Factor<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Factor = Factor - <span style="color: #FF0000;color:#800000;">1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">double</span> xMOd11 = <span style="color: #FF0000;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xMOd11 = <span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">11</span> - <span style="color: #000000;">&#40;</span>Suma % <span style="color: #FF0000;color:#800000;">11</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> % <span style="color: #FF0000;color:#800000;">11</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> s = Convert.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span>xMOd11<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>xMOd11 == <span style="color: #FF0000;color:#800000;">10</span> &amp; DigitoVerificador == <span style="color: #808080;">"K"</span><span style="color: #000000;">&#41;</span> | <span style="color: #000000;">&#40;</span>s == DigitoVerificador<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Nos Vemos.</p>
]]></content:encoded>
			<wfw:commentRss>http://geoavila.com/validar-un-nitguatemala-en-c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
