01/10/2018, 09:32

Return trong c#

Trong trường hợp nó return aiResponse;, xuống dưới gặp return null tiếp thì cuối thì nó return cái nào ạ?
public AIResponse VoiceRequest(float[] samples)
{
try {

			var trimmedSamples = TrimSilence(samples);
		
			if (trimmedSamples != null) {
			
				var pcm16 = ConvertIeeeToPcm16(trimmedSamples);
				var bytes = ConvertArrayShortToBytes(pcm16);

				var voiceStream = new MemoryStream(bytes);
				voiceStream.Seek(0, SeekOrigin.Begin);
			
				var aiResponse = VoiceRequest(voiceStream);
				return aiResponse;
			}

		} catch (AIServiceException) {
			throw;
		} catch (Exception e) {
			throw new AIServiceException(e);
		}

		return null;
	}
Quân viết 11:40 ngày 01/10/2018

Gặp lệnh nào trước thì return chỗ đó, return là kết thúc hàm luôn

Bài liên quan
0